Hello, im writing a program that takes a command from the command prompt thats a file name and two dimensions, and then makes a maze of those dimensions in the file.
It's supposed to then take commands from stdin consisiting of a string and integers. I want to use scanf to take the input and put it as needed, so it'd look something like this:
scanf("%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);
I don't want to use a static array to hold the string, so I was wondering if I called Char str1[] with no indication to it's size, if it would automatically become big enough to hold the %s. Also, I want to see how many successful items are put in place with the scanf,
so itd look like
intSuccess = scanf("%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);
Would doing that make a new instance of scanf to recieve stuff? Or would i need to use something like
char bufferStr[100];
gets(&bufferStr);
sscanf(bufferStr, "%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);
intSuccess = sscanf(bufferStr,"%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);
It's supposed to then take commands from stdin consisiting of a string and integers. I want to use scanf to take the input and put it as needed, so it'd look something like this:
scanf("%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);
I don't want to use a static array to hold the string, so I was wondering if I called Char str1[] with no indication to it's size, if it would automatically become big enough to hold the %s. Also, I want to see how many successful items are put in place with the scanf,
so itd look like
intSuccess = scanf("%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);
Would doing that make a new instance of scanf to recieve stuff? Or would i need to use something like
char bufferStr[100];
gets(&bufferStr);
sscanf(bufferStr, "%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);
intSuccess = sscanf(bufferStr,"%s %d %d %d %d", &str1, &int1, &int2, &int3, &int4);