On the discussion of dynamic memory here: \"Intro to C Pointers and Dynamic Memory\"
The author states:
A memory block like this can effective
Variable-length automatic arrays are allowed in ISO C99, and as an extension GCC accepts them in C90 mode and in C++. So, don't foget to set compiler flag -std=c99 or -std=gnu99. Following example will work
#include
int main()
{
int n;
printf("\n\tEnter the number of digits: ");
scanf("%d", &n);
char str[n];
for(int i=0; i < n; i++) {
scanf("%s", &str[i]);
}
printf("\n\tThe entered digits are: %s", str);
return 0;
}
I garantee that :-)