[C language] Printf statement line break

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:

    printf("New line "
  2. backslash
    printf("New line \
  3. several printf
    printf("New line ");

    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);


This entry was posted in C language (en). Bookmark the permalink.

Leave a Reply

🇬🇧 Attention! Comments with URLs/email are not allowed.
🇷🇺 Комментарии со ссылками/email удаляются автоматически.