Concatenating cstrings

This is a discussion on Concatenating cstrings within the C++ Programming forums, part of the General Programming Boards category; Hello all. Im having trouble combining two c strings into one with a period in the middle. Heres what I ...

  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-03-2008, 12:10 AM
  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, 06:34 PM
  4. Concatenating two static queues?
    By difficult.name in forum C Programming
    Replies: 2
    Last Post: 10-19-2004, 12:19 AM
  5. concatenating two strings
    By js_badboy in forum C Programming
    Replies: 2
    Last Post: 09-08-2003, 09:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21