What is the best way to write a few lines of strings together?
i.e.
Line2
Line2
Line3
I attempted it this way but it doesn't seem to work.
Code:printf ( "Line1" ); printf ( "Line2" ); printf ( "Line3" );
What is the best way to write a few lines of strings together?
i.e.
Line2
Line2
Line3
I attempted it this way but it doesn't seem to work.
Code:printf ( "Line1" ); printf ( "Line2" ); printf ( "Line3" );
Code:printf("Line1\nLine2\nLine3\n");
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
You need to account for the newlines, e.g.,
Code:puts("Line1\nLine2\nLine3");
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Lemme guess: "Line1Line2Line3"
printf doesn't add a newline('\n'). You have to include it, or them:
Code:printf ( "Line1\n" ); printf ( "Line2\n" ); printf ( "Line3\n" ); or printf ( "Line1\nLine2\nLine3\n" );
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge