How can I use a variable to specify the field length when using scanf. For example:
char word[20+1];
scanf(file, \"%20s\", word);
Also, is
There's a difference here between C90, C99, and C++. In C++, you can use any integral constant expression, so
const int max_string_size = 20;
int this_string[max_string_size + 1];
is legal. In C99, the expression doesn't have to be constant; if it isn't, you get a variable length array. In the older C90, the expression couldn't include variables, so the above would not compiler, and you'd have to use
#define MAX_STRING_SIZE 20
char this_string[MAX_STRING_SIZE + 1];