Creating one variable from two

This is a discussion on Creating one variable from two within the C++ Programming forums, part of the General Programming Boards category; .. or whatever Im trying to create two filenames from what the user types in: { ... ofstream destination_blg; ofstream ...

  1. #1
    Peter_D3T
    Guest

    Question Creating one variable from two

    .. or whatever

    Im trying to create two filenames from what the user types in:

    {
    ...
    ofstream destination_blg;
    ofstream destination_bal;
    char filen[20];
    cout << "Enter Filename:\t"
    cin >> filen;
    ...
    /*
    Somehow a method to join filen and then ".blg" and ".bal" in herre.
    To produce (filen = bob) bob.blg and bob.bal and give destination_blg = "bob.blg" etc
    */
    ...
    ofstream.open(destination_blg);
    ofstream.open(destination_bal);
    ...
    }

    I have tried using:

    #define FFN(p, q) (p##q)
    with:
    destination_blg = FFN(filen, "blg");
    destination_bal = FFN(filen, "bal");

    but get the error "Unknown symbol filenbal", or "Expected ')'"

    Someone who could help me please.

    Thx.

    -D3T

  2. #2
    Unregistered
    Guest
    just use
    Code:
    stcpy(filen2,filen);//we copy filen word for word
    strcat(filen,".blg");//change extension
    strcat(filen2,".bal");//change extension on 2

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    3
    These are in iostream.h?
    or another such as conio?

  4. #4
    Unregistered
    Guest
    Code:
    #include <string.h>

  5. #5
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    Not that this has anything to do with the actual question, but you could create 1 numeric variable from 2 using the binary operators.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C variable
    By webstarsandeep in forum C Programming
    Replies: 1
    Last Post: 10-23-2008, 01:26 AM
  2. Static Local Variable vs. Global Variable
    By arpsmack in forum C Programming
    Replies: 7
    Last Post: 08-21-2008, 03:35 AM
  3. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 12:25 PM
  4. Static global variable acting as global variable?
    By Visu in forum C Programming
    Replies: 2
    Last Post: 07-20-2004, 08:46 AM
  5. creating a filename based on a variable
    By Waldo2k2 in forum C++ Programming
    Replies: 3
    Last Post: 05-22-2002, 05:27 PM

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