VS2013 don't support variable length declaration.
You can't enter a non-constant value between the brackets when you declare your array:
char a[b];
Since you're getting size from the user, the compiler can't tell ahead of time how much memory it needs for char array a
. The easiest thing to do here (especially for an exercise) is to just choose a relatively large value and make that the constant allocation, like:
char a[1024];
And then if you want to be careful (and you should) you can check if (b > 1024) and print an error if the user wants b
that's beyond the pre-allocated bounds.
If you want to get fancy, you can define char a[]
with no pre-set size, like char *a;
and then you allocate it later with malloc:
a = (char *)malloc(sizeof(char) * b);
Then you must also free char a[]
later, when you're done with it:
free(a);
Hope it helps!