I am trying to print out a two dimensional array of strings using the array shown below and associate each phrase with a number from 0 to 3. When I try to print out each phrase the words get matched together and print out incorrectly.
char PhraseList[4][10]= {" Work Hard","Play Hard ","Enjoy","Live"};
How can I print out each phrase on a separate line so that " Work Hard" prints out on one line then "Play Hard " on another line and then "Enjoy" on another etc. Also how can I associate each phrase with a number? Any help\suggestions will be greatly appreciated!
Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
int main()
{
char PhraseList[4][10]= {" Work Hard","Play Hard ","Enjoy","Live"};
int i;
for(i=0; i<4; i++)
{
printf("%s \n", PhraseList[i]);
}
printf("\n\n");
system("PAUSE");
return 0;
}
Output:
Work HardPlay Hard Enjoy
Play Hard Enjoy
Enjoy
Live
Press any key to continue . . .
system("pause")then why not usesystem("echo Work Hard")(etc.) as well?