# Input Problem

• 07-26-2010
slapgun87
Input Problem
I need a little help here please. I'm having the user input integers until EOF is indicated.

So here's my error:

------ Build started: Project: Project10, Configuration: Debug Win32 ------
Compiling...
project10.c
project10.obj : error LNK2001: unresolved external symbol _array
C:\C\Project10\Debug\Project10.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\C\Project10\Project10\Debug\BuildLog.htm"
Project10 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Here's my code:
Code:

```#include <stdio.h> int size = 0; int array[]; void userinput(int *array){         int scanf_return = 0;         do{                 printf("\nEnter an integer or EOF to terminate: ");                 scanf_return = scanf_s("%d", &array[size++]);         }         while (scanf_return != EOF); }         void swap(int *a, int *b){     int c;     c=*a;     *a=*b;     *b=c;     } void usersort(int *array){     int i;     for(i=0;i<size-1;i++){                     if(*(array+i)>*(array+i+1)){                                 swap(array+i,array+i+1);                                 i-=2;                                 }                     }         } int findmin(int *array){     return array[0];     } int findmax(int *array){     return array[size-1];     } void printminmax(int min,int max){     printf("The min is: %d \nThe max is: %d\n", min,max);     } void printarray(int *array){     int i;     printf("The elements of the sorted array from smallest to largest:\n");     for(i=0;i<size;i++) {                         printf("%d\t",array[i]);                         }     } int main(){         int min,max;     userinput(array);     usersort(array);     min = findmin(array);     max = findmax(array);     printminmax(min,max);     printarray(array); }```
• 07-26-2010
Elysia
Your "array" doesn't have a size. It must have a size.
As a side note, remove your global variables and make them local. Just as you pass the array, pass its size as well.
• 07-26-2010
slapgun87
Edited
I've set the size to 10 but if I enter "EOF" I get a continuous loop. What else do I need to do to terminate the program?

Thanks!
• 07-26-2010
sean
The string "EOF", when entered at the console, is not the same as the constant EOF that you refer to in your code. EOF is actually a code sent by your OS. You can enter that particular value at the console by pressing Ctrl+D.
• 07-26-2010
slapgun87
Thanks! I got it now! Ctrl Z works wonders!