In-Class Practice

String Output

Consider the following incomplete program that displays the string "This is a string".  Add code to:

  1. allocate memory for the string
  2. initialize that memory to hold the phrase
  3. pass the string to the display() function
  4. in the display() function, send the string to the standard output stream so that the string appears left-justified in a field of 20 characters
 // String Output
 // stringOutput.c

 #include <stdio.h>

 int main(void)

     display(                                    );

     return 0;

 void display(                                            )


   Printer Friendly Version of this Page print this page     Top  Go Back to the Top of this Page

  Designed by Chris Szalwinski   Copying From This Site   

Creative Commons License