I have the following statement:
printf("name: %s\targs: %s\tvalue %d\tarraysize %d\n", sp->name, sp->args, sp->value, sp->arraysize);
I want to break it up. I tried the following but it doesn't work.
printf("name: %s\t args: %s\t value %d\t arraysize %d\n", sp->name, sp->args, sp->value, sp->arraysize);
How can I break it up?
Use triple quotes to create a multiline string It is the simplest method to let a long string split into different lines. You will need to enclose it with a pair of Triple quotes, one at the start and second in the end. Anything inside the enclosing Triple quotes will become part of one multiline string.
The printf functions are implemented using a variable-length argument list. Arguments specified after the format string are passed using their inherent data type. This can cause problems when the format specification expects a data object of a different type than was passed.
"\ operator is used to separate a multiline macro in C language" Explanation: In C language, macros are used to substitute a string, which in turn defined as a macro substitution. In C, macros can be used to replace a first part using a second part.
Most of the compilers takes each parameter of printf() from right to left. So in the first printf() statement, the last parameter is x++, so this will be executed first, it will print 20, after that increase the value from 20 to 21. Now print the second last argument, and show 21.
If you want to break a string literal onto multiple lines, you can concatenate multiple strings together, one on each line, like so:
printf("name: %s\t" "args: %s\t" "value %d\t" "arraysize %d\n", sp->name, sp->args, sp->value, sp->arraysize);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With