Homework 12: Pointers and Separate Compilation Homework

Wednesday, April 25, 2012     


[Up] [Previous Homework] [Next Homework]


Complete the following:

Solution hw12.c and reverse.c

  1. NOTE: You need to start indenting your programs properly. Points will be taken off for not indenting this homework appropriately
  2. Reminder to look at CMSC104 Indentation Standards
  3. You will create two .c files for this homework, BOTH must be submitted
  4. You are going to implement a program to reverse strings the user types in
  5. One file, reverse.c, will implement a function with the following function definition:

    void reverse(char *in_str, char *out_str);
    

  6. The second file, hw12.c, will implement main()
  7. Main should define two arrays of characters, one to store user input, and one to store the reversed string, each 30 characters long
  8. Main should then ask the user to input a string
  9. Main should pass the user input string as the first argument to the reverse() function
  10. Main should pass the second string as the second argument to reverse() as the output memory for the reversed string
  11. After calling reverse, main should print out the reversed string, followed by the original string
  12. An example output is below

    linux2[1]% ./hw12
    Input string: hey_this_is_a_test
    Reversed string: tset_a_si_siht_yeh
    Original string: hey_this_is_a_test
    

  13. Create a script of you running your program three times.
  14. Once you are done, use submit to submit three files, hw12.c reverse.c and typescript

    linux3[1]% submit cs104_sheets hw12 hw12.c reverse.c typescript