string variable + "some string" ??

This is a discussion on string variable + "some string" ?? within the C Programming forums, part of the General Programming Boards category; How can I add an "string" to a string variable to make it into one big string? I have code ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    26

    string variable + "some string" ??

    How can I add an "string" to a string variable to make it into one big string? I have code that returns the current path of the program:

    char cDir[150];
    GetCurrentDirectory(150,cDir);

    Now I need to open a file within this folder, however I need to add the filename at the end of cDir:

    char szPath[] = cDir & "AnnualPlan.txt"; -this doesn't work, I also tried it with a + and nothing, it gives error:

    "invalid operands to binary +"

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You can't add strings. You can concatenate them, provided you have enough room. Consider strcat. You'll want to read up on all of the string functions.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 01:56 PM
  3. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  4. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 02:26 PM

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