Right Click to Search

Sunday, April 18, 2025

Multiline Printf in C / Breaking Printf Statement upto multiple lines .



Break long Printf Statement Upto Multiple Lines in C :

Printf statement is used for displaying text,message or output of the program.So question is that "Can a long printf statement be broken up into multiple lines ?" Its answer is Yes we have 3 tricks by which you can break printf upto multiple lines
3 ways of Multiline
  1. Using "Backward Slash".
  2. Using "Double Quotes"
  3. By Dividing Printf into Many Small Printf's
Let us Discuss one by one -
1 . Using "Backward Slash".
#include<stdio.h>
void main()
{
printf("C Programming is \
funny Language ");
}
Output :
C Programming is funny Language
Note :
  1. One printf can be broken into 'n' number of lines using "Backslash"
  2. No need to Close "Double Quotes" after first line.
  3. Opening Double Quote always on First Line while Closing Double Quote always on Last Line.

2 . Using "Double Quotes"
#include<stdio.h>
void main()
{
printf("C Programming is "
"funny Language ");
}
Output :
C Programming is funny Language
Note :
  1. Each Line needs Opening and Closing "Double Quote".

3 . Break Long Printf in Small PRintf's
#include<stdio.h>
void main()
{
printf("C Programming is ");
printf("funny Language ");
}
Output :
C Programming is funny Language

Stumble
Delicious
Technorati
Twitter
Facebook

0 Comments:

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email

 

Learn C Programming Copyright © 2010 LKart Theme is Designed by Lasantha, Free Blogger Templates