-1
printf("%c Trying to forget someone you love is like trying to remember someone you never knew \n\n",3);

become like in vb.net:

printf("%c Trying to forget someone you love is like trying to" & 
"remember someone you never knew \n\n",3); 

We add the next string on new line.... How to connect the string in C language.

jeff_ang24
  • 119
  • 4
  • 12
  • 5
    Just leave out the ampersand. Two juxtaposed string literals will become one. (This won't print a newline, though, and paste "to" and "remember" together in your case.) – M Oehm Sep 22 '14 at 05:40
  • Also see [here](http://stackoverflow.com/questions/797318/how-to-split-a-string-literal-across-multiple-lines-in-c-objective-c) for a more detailed answer, which also gives an alternative. – M Oehm Sep 22 '14 at 05:43
  • Thanks!!! I'm newbie in C.... – jeff_ang24 Sep 22 '14 at 05:44

3 Answers3

3

Two ways:

printf("%c Trying to forget someone you love is like trying to "
       "remember someone you never knew \n\n",3);

String literals can be written like that with multiple quoted parts. It is still just one string. That way can have indentation and comments in between.


printf("%c Trying to forget someone you love is like trying to \
remember someone you never knew \n\n",3);

You can split string literal by having backslash as last char in line. There will ne no newline in the resulting string, if you want that use \n\ at the end. Also if you indent the 2nd line, that whitespace will go into the string, usually not what you want.

hyde
  • 60,639
  • 21
  • 115
  • 176
0

Just put the strings after each other without any operator in between.

printf("%c Trying to forget someone you love is like trying to "
       "remember someone you never knew \n\n", 3);

It will be treated like one long string by the compiler.

SzG
  • 12,333
  • 4
  • 28
  • 41
0

You just need to write

printf("%c Trying to forget someone you love is like trying " 
       "to remember someone you never knew \n\n",3);

Two juxtaposed string literals will become one.