-
Notifications
You must be signed in to change notification settings - Fork 27
/
todo.cpp
51 lines (45 loc) · 911 Bytes
/
todo.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>
/**
* A class that contains a character array, provides a method for reading standard input into it.
*/
class Test{
public:
Test(){
}
/**
* Scan a string into the character array.
*/
void a(){
printf("Input position:");
scanf("%d", &position);
if(position > 9)
position = 9;
if(position < 0)
position = 0;
printf("Input a string:");
scanf("%s", &buffer);
printf("You entered string: %s\n", buffer);
}
char buffer[10];
int position;
};
int a(){
int things[10];
printf("things addr:%p\n", &things);
for(int i = 0; i < 10; i++){
things[i] = i;
}
int input = -1;
while(input != 0){
Test* aTest = new Test();
aTest->a();
printf("Input value:");
scanf("%d", &input);
printf("Setting index %d (%p) to %d\n", aTest->position, things + aTest->position, input);
things[aTest->position] = input;
}
}
int main(){
a();
}