Question

I'm using Visual Studio 2013 to create a C program.

I want to test the formatstring parameters.

The only thing I'm trying to do is the following

int main(int argc, char *argv[]){
    printf("Test: %2$s\n","asdf","2asdf");
    return 0;
} 

If i say Test: %s it uses the first parameter. But I want it to use the second parameter. But my output here is Test: $s

What am I doing wrong? Is there another way to specify the second parameter to be used?

Was it helpful?

Solution

Format specifier like %2$s in printf to specify the second parameter is not part of standard C, but a POSIX extension. Visual Studio doesn't support it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top