I forgot how to properly “cut” long pieces of printf
, so I decided to write this cheat sheet.
Let’s say you have a long printf expression and you need to break it into several smaller ones for readability (or to fit when embedding on a site, for example). There are three ways:
- quotes
printf("New line " "please");
- backslash
printf("New line \ please");
- several
printf
printf("New line "); printf("please");
So it goes. You can’t just take and … break the string inside the quotes. However, remember that you can safely do this for arguments, for example, like this:
printf("New %d line %c", argument1, argument2);