On Fri, 12 Dec 2003, Aryan Ameri wrote:
> int tmp, cnt = 0;
> static int arr[cnt];
> printf( "Enter Number\n");
> scanf( "%d", &tmp);
> while ( (tmp = getchar() ) != EOF ) {
> arr[cnt] = tmp;
> cnt += 1;
> static int arr[cnt];
> printf( "Enter Number\n");
> scanf( "%d", &tmp);
> }
>
> return 0;
> }
>
> This sounded logical to me. But the compiler (gcc 3.2) gives me a syntax
> error saying that 'storage size of 'arr' isn't constant'. Well, I don't
> want it to be constant!
Hi there,
This is obviously wrong. Array sizes are needed (by C compilers) during
compile time. This is the single most cause of buffer overflows in C and
C++ programs.
What you need is a "linked list". You can find examples in any C book you
find in your nearest book shop or library.
cheers,
Hossein
_______________________________________________
bna-linuxiran mailing list
[EMAIL PROTECTED]
http://mail.nongnu.org/mailman/listinfo/bna-linuxiran