taking input from file

Signed-off-by: BuildTools <unconfigured@null.spigotmc.org>
This commit is contained in:
BuildTools
2021-01-03 16:45:34 -05:00
parent f4cbeaeee1
commit aa17c68aa5

8
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) {
while(end_scan) {
printf("Enter a number: ");
scanf("%d", &(arr[pos]));
if (scanf("%d", &(arr[pos])) == EOF) {
end_scan = 0;
}
//scanf("%d", &(arr[pos]));
if( arr[pos] == 0 ) {
break;
}