Compare commits

...

2 Commits

Author SHA1 Message Date
BuildTools
7cec159017 added prompt for end
Signed-off-by: BuildTools <unconfigured@null.spigotmc.org>
2021-01-03 16:46:18 -05:00
BuildTools
aa17c68aa5 taking input from file
Signed-off-by: BuildTools <unconfigured@null.spigotmc.org>
2021-01-03 16:45:34 -05:00

10
sum.c
View File

@@ -11,11 +11,15 @@ int main() {
int size = 1;
int sum = 0;
int pos = 0;
int end_scan = 1;
int* arr = malloc(size * sizeof(int));
while(TRUE) {
printf("Enter a number: ");
scanf("%d", &(arr[pos]));
while(end_scan) {
printf("(Type EOF to end) Enter a number: ");
if (scanf("%d", &(arr[pos])) == EOF) {
end_scan = 0;
}
//scanf("%d", &(arr[pos]));
if( arr[pos] == 0 ) {
break;
}