Lab 8 - More Fun With Strings

Overview | Requirements | Compilation | Example | Turn in Work  

Overview

Your job is to implement 2 string related functions (listed below). You will be given a test program to test the functions you implement.

Requirements

You must implement the following functions:

void stringConcatenate(char dest[], const char src[]);

stringConcatenate appends the src string to the dest string overwriting the `\0' character at the end of dest, and then adds a terminating `\0' character. The strings may not overlap. Assume dest points to a large enough array to hold both strings.

For example, the concatenation of the strings "this is a r" and "eally big string" is "this is a really big string".

void stringCopy(char dest[], const char src[]);

stringCopy copies the string pointed to by src (including the terminating `\0' character) to the array pointed to by dest. Assume dest points to a large enough array to hold both strings.

You are to implement the above functions only. You should make your implementation of these functions as efficient as possible. You will be provided with a file called lab8.c which contains main(). This main() function is designed to test the functions above. lab8.c can be downloaded here. The header file which contains the function prototypes for both str.c and str2.c can be downloaded here

Compilation Instructions

Name the file containing the 2 strings methods str2.c You can compile your program with Eclipse and add the run time arguments either from the command line or by opening the run dialog selecting the arguments tab and typing in the two arguments:
"multiple words" potato
See lab 6 Compilation Instructions

C:\workspaceC\lab8\Debug>lab8 "multiple words" potato

Example Output

main() expects 2 arguments to be passed on the command line. These two arguments are used to test your program. An example invocation follows:

C:\workspaceC\lab8\Debug>lab8 "multiple words" potato
14: length of "multiple words"
6: length of "potato"
concatenation: "multiple wordspotato"
copy "multiple words": "multiple words"
copy "potato": "potato"

Turn In Work

After you have completed the luminance program and have an output similar to the example usage, please submit your work via UNCW webmail by following these simple steps.

  1. str2.c source code attachment
  2. copy and paste this subject line: CSC 112 Lab 8 str2.c

Confirmations: A student can then be assured that their assignment has been submitted based on the return email which is sent only if the above requirements are met. The student should not delete the confirmation email.  Any work submitted after 11:59 PM on Wednesday October 29th will be late.