help combining strings

Home Forums C Programming help combining strings

This topic contains 1 reply, has 2 voices, and was last updated by  GWILouisaxwzkla 9 years, 4 months ago.

  • Author
  • #2151


    Hi, I’m a total newbie at this. I’m really struggling here. any help would be awsome!
    the instructions are: Include the string library functions strlen(), strcat(), and strncat() within a function having the prototype concat(char string1[], char string2[], int maxlength)

    Here is what I need to do:
    read in string 1
    read in string 2
    pass both strings to the concat function
    Once I am in the function, I need to get the length of both strings.
    if the length of string1 + the length of string 2 is greater than the maximum number of characters allowed
    use strncat and limit the number of characters copied to maximumnumber – length of string 1
    otherwise use strcat and copy all of string 2 into string 1

    I could use some help with the code. Not sure what I’m doing and again, any help would be great. thanks
    what I have so far is…

  • #3472

    Could try:

You must be logged in to reply to this topic.