fork download
  1. // Lyrics from David Bowie's Heroes
  2. #include <stdio.h>
  3.  
  4. // You can store many sentences in one string, use
  5. // the continuation character (the "\") after each line. You
  6. // can add new lines and other special characters as needed
  7. // to get the printing effect you need.
  8.  
  9. #define HEROES_VERSE1 "\nI, I wish you could swim \
  10. \nLike the dolphins, like dolphins can swim \
  11. \nThough nothing, \
  12. \nnothing will keep us together \
  13. \nWe can beat them, for ever and ever \
  14. \nOh we can be Heroes, \
  15. \njust for one day"
  16.  
  17. int main ()
  18. {
  19.  
  20. // You can store a quote in a variable as well.
  21. // It does not matter if you put each sentence on a new line,
  22. // the C program will just print characters until the null
  23. // terminator is encountered
  24.  
  25. char heroes_verse2 [ ] = {"\nI, I will be king\nAnd you, you \
  26. will be queen\nThough nothing will drive them away \nWe can \
  27. be Heroes, just for one day\nWe can be us, just for one day"};
  28.  
  29. char song [5000]; /* store a song */
  30.  
  31. printf ("\nThe first two verses of David Bowie's Heroes:\n");
  32. printf ("%s", HEROES_VERSE1);
  33. printf ("\n");
  34. printf ("%s", heroes_verse2);
  35.  
  36. /* Let store the two verses in one variable */
  37. strcpy (song, HEROES_VERSE1); /* input is a constant */
  38. strcat (song, "\n"); /* input is a new line character */
  39. strcat (song, heroes_verse2); /* input is a variable */
  40.  
  41. /* print the song */
  42. printf ("\n\n\n*** David Bowie's Heroes ***\n");
  43. printf ("%s", song);
  44.  
  45. /* print number of characters in the song */
  46. printf ("\n\nNumber of characters in the the song is: %i \n",
  47. strlen (song));
  48.  
  49. return (0);
  50. }
  51.  
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
The first two verses of David Bowie's Heroes:

I, I wish you could swim 
Like the dolphins, like dolphins can swim 
Though nothing, 
nothing will keep us together 
We can beat them, for ever and ever 
Oh we can be Heroes, 
just for one day

I, I will be king
And you, you will be queen
Though nothing will drive them away 
We can be Heroes, just for one day
We can be us, just for one day


*** David Bowie's Heroes ***

I, I wish you could swim 
Like the dolphins, like dolphins can swim 
Though nothing, 
nothing will keep us together 
We can beat them, for ever and ever 
Oh we can be Heroes, 
just for one day

I, I will be king
And you, you will be queen
Though nothing will drive them away 
We can be Heroes, just for one day
We can be us, just for one day

Number of characters in the the song is: 342