-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp3.cpp
More file actions
38 lines (31 loc) · 696 Bytes
/
temp3.cpp
File metadata and controls
38 lines (31 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
// Output prompt
cout << "Press any key to continue..." << endl;
// Set terminal to raw mode
system("stty raw");
// Wait for single character
char input = getchar();
string s;
int i = 0;
while( input >= '0' and input <='9')
{
// Echo input:
cout << "--" << input << "--";
s = s + input;
//s[i++] = input;
cout << "s=" << s << endl;
input = getchar();
}
cout << "s=" << s << endl;
double d;
d = stod(s);
cout << "d=" << d << endl;
// Reset terminal to normal "cooked" mode
system("stty cooked");
// And we're out of here
return 0;
}