My exposure to arrays and pointers are bit limited. And concatened strings even less ( it was not covered in my class so I had to use my book. ) So I know there are errors. I can not use any of C string libary functions. Thoughts?
A "string" is really just an array of char, whose last used element is null (zero). The actual memory may be larger. For example, you can declare an array of twenty characters:
char s[ 20 ];
which reserves space for the twenty characters.
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
You can then fill that space with strings strictly less than twenty characters long.
strcpy( s, "Hello" );
Which gives us the following (where ■ represents the null character).
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│ H │ e │ l │ l │ o │ ■ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
Since there is room, you can add more characters to it:
strcat( s, " world!" );
giving
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│ H │ e │ l │ l │ o │ │ w │ o │ r │ l │ d │ ! │ ■ │ │ │ │ │ │ │ │
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
You can always change the string, so long as you don't try to access characters outside the indices 0..19.
s[ 5 ] = '?';s[ 6 ] = 0;
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│ H │ e │ l │ l │ o │ ? │ ■ │ o │ r │ l │ d │ ! │ ■ │ │ │ │ │ │ │ │
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
This of course will display as "Hello?", since that first null terminates the string (not the available memory). Always make sure you have enough memory to do things like string concatenations.