Multiline Story String

vegaseat 2 Tallied Votes 111 Views Share

This code shows you how to build a multiline story string that should display similarly to way it shows in the code. It should be relatively easy to maintain.

// build a long story string using \
// tested with Pelles C

#include <stdio.h>

int main()
{
  char *story; // will point to the story in the string constant table

  // all the story lines originally started at the far left
  // this would make it easier to change/edit
  // but some code-fields insist on automatic indenting
  story = "\
A man traveling by plane was in urgent need of the rest room facility,\n\
but each time he tried, it was occupied.  The flight attendant, aware\n\
of his predicament, suggested he use the attendants' ladies room, but\n\
cautioned him not to press any of the buttons.\n\
\n\
There next to the paper roll were 4 buttons marked:\n\
\n\
          WW          WA          PP          ATR\n\
\n\
Making the mistake so many men make of not listening to a woman, he\n\
disregarded what she had said, as his curiosity got the best of him. He\n\
carefully pressed the WW button, and immediately a gentle flush of\n\
Warm Water sprayed on his bare bottom. He thought  \"Wow!  These gals\n\
really have it nice!\"\n\
\n\
So a little more boldly he pressed the WA button.  Warm Air blew across\n\
his wet bottom and dried it easily.  \"Ah ha!\"  he thought, \"no wonder\n\
these women take so long in the bathroom with these kind of services!\"\n\
\n\
So he pushed the next button,  PP,  with anticipation.  A soft\n\
disposable Powder Puff swung below him and dusted his bottom lightly\n\
with talcum.\n\
\n\
\"Man, this is great!\" he thought, as he reached for the ATR button.\n\
\n\
When he awoke in the hospital, the morphine was just wearing off.  He\n\
buzzed the nurse to find out where he was and what had happened. He\n\
explained in a rather high pitched voice that the last thing he\n\
remembered was intense pain in the ladies' room on the plane.\n\
\n\
The nurse explained  \"Yes, you must have been having a great time,\n\
until you pushed the  AUTOMATIC  TAMPON  REMOVAL  button!\"\
";
  
  printf("%s\n\nstory length = %d", story, strlen(story));

  getchar();
  return 0;
}
bumsfeld 413 Nearly a Posting Virtuoso

I would be temded to bring the story in from a text file, but than of course you need to distrubute two files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.