Thread: Concatenating cstrings

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    16

    Concatenating cstrings

    Hello all. Im having trouble combining two c strings into one with a period in the middle. Heres what I have so far. I get errors on the line where i commented. Im not sure exactly how to approach the problem of combining them. Can I use the + operator like I am? Also cant use strcat so thats out =) Thanks all! (btw not looking for the code answer, just help in the direction on how i can accomplish this)

    Code:
    
    int stringCat(char filename[265], char suffix[10]){
    
    filename = filename + "." + suffix; /// Heres where im looking for help
    }
    return filename;
    }

  2. #2
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    you could go at it one character at a time...
    Don't quote me on that... ...seriously

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    92
    You can create temporary char array to connect filename and suffix one by one. Then copy the temp char array into filename.

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    16
    never thought of that =) Thanks all!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concatenating in linked list
    By drater in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 11:10 PM
  2. Replies: 5
    Last Post: 02-11-2008, 01:36 AM
  3. concatenating strings?
    By liri in forum C Programming
    Replies: 11
    Last Post: 08-24-2007, 05:34 PM
  4. Concatenating two static queues?
    By difficult.name in forum C Programming
    Replies: 2
    Last Post: 10-18-2004, 11:19 PM
  5. concatenating two strings
    By js_badboy in forum C Programming
    Replies: 2
    Last Post: 09-08-2003, 08:27 PM