diff --git a/sum.c b/sum.c index 533a801..cb90204 100644 --- a/sum.c +++ b/sum.c @@ -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; }