Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

newb question....

Name: Anonymous 2006-04-11 18:08

Check this c++ code:

    string file_opened ("lol.txt");
    ofstream communism;
    communism.open (file_opened);

The thing keeps writing to a file called file_opened rather than lol.txt.  How do I get the thing to treat the variable as the string that makes it up?  Tutorials say nothing about this...  They always just show you how to write strings directly to output.

Also, while I'm at it, (I suspect this is related) if I wanted to generate the names of variables using code, how would I do it?  Say I wanted to initialize ten variables, name1 - name10, but I didn't feel like typing out every one.  Here's what I would write intuitively: 

while (i < 9)  {
    i+=1;
    int namei;
};

But I know this isn't right.

Name: Anonymous 2006-05-07 3:25

a method is a fancy way of saying a function or procedure that's in an object.  and yes, someString.c_str() is an example of a method (c_str) in an object (someString).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List