Usually we use printf with a string literal for the format,
e.g.
printf("%d flowers\n",count);

But if I put the format in a variable (as opposed to a string literal), I
find that
escape processing does not occur.

so using the program:

void main(int ac, char **av)
{
        printf(av[1],av[2]);
}

and running (# is the prompt)
# ./test "%s flowers\n" 7

give the output
7 flowers\n#

[same with # ./test "%s flowers\\n" 7 which yields 7 flowers\\n# ]

Any idea how to get the variable containing the format to undergo escape
sequence processing?

Thanks,
Dan

Reply via email to