Thread: helpp

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220

    helpp

    in
    Code:
    ofstream a_file("data.1")
    how can i make the name of the archive be a variable

  2. #2
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    Take off the quotes.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    I don't know how data.1 is a variable name, as '1' is not an acceptable variable declaration, nor is anything with a '.' in it.
    Sent from my iPadŽ

  4. #4
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    A variable is something that holds data.
    Put what you want into the variable.

    Code:
    #include <iostream>	
    #include <fstream>
    
    
    using namespace std;
    
    int main()
    {
    
    	ofstream out;
    
    	char file_name[16];
    	cout << "Enter the name of the file (including ext, IE test.txt: ";
    	cin >> file_name;
    
    	out.open(file_name);
    
    	out << "See, like this.";
    
    	out.close();
    
    	return 0;
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Helpp Do Not Know Where To Start
    By sjcc in forum C Programming
    Replies: 6
    Last Post: 03-12-2009, 08:50 AM
  2. simple inheritance problem please help:P
    By miguel811 in forum C++ Programming
    Replies: 9
    Last Post: 02-19-2009, 02:55 AM
  3. C++ helpp
    By nooneelse in forum C++ Programming
    Replies: 6
    Last Post: 09-13-2008, 05:55 PM
  4. helpp c programming assignment :(
    By robdiddy in forum C Programming
    Replies: 2
    Last Post: 04-27-2006, 07:15 AM
  5. helpp
    By slurpy in forum Game Programming
    Replies: 5
    Last Post: 04-04-2006, 12:40 AM