![]() |
|
#1
|
|||
|
|||
File Output - Using Variable for FileNameHi,
Can someone give me an idea how I would go about using a variable in my program to determine what a name of a file should be when output is written? My code is below: CPP / C++ / C Code:
I am unsure how to change the format in my #define statement to accept a variable name instead of hardcoding the name. Any suggestions are appreciated. Thanks! |
|
#2
|
|||
|
|||
Re: File Output - Using Variable for FileNameQuote:
There is no way to convert a macro argument into a character constant. Just use a program variable. CPP / C++ / C Code:
Output: Code:
...and please consider using more whitespace in your code! :davis: |
|
#3
|
|||
|
|||
Re: File Output - Using Variable for FileNameSo, if I wanted to make the filename be an element of my structure, I would do something like:
CPP / C++ / C Code:
It created the file, but didn't dump any of the data. |
|
#4
|
||||
|
||||
Re: File Output - Using Variable for FileNameWrong whitespace. He meant horizontal (between operators and such), not vertical:
CPP / C++ / C Code:
CPP / C++ / C Code:
Whatyouhaveisakintothistext.Veryhardtoread. __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#5
|
|||
|
|||
Re: File Output - Using Variable for FileNameOkay thanks. So, if I wanted to make the filename be an element of my structure, I would do something like:
CPP / C++ / C Code:
It created the file, but didn't dump any of the data. |
|
#6
|
|||
|
|||
Re: File Output - Using Variable for FileNameThanks, I figured out my problem. I appreciate your help!
|
|
#7
|
|||
|
|||
Re: File Output - Using Variable for FileNameIf I wanted to append a filetype, .txt, would I be able to using this same example?
CPP / C++ / C Code:
|
|
#8
|
|||
|
|||
Re: File Output - Using Variable for FileNameQuote:
The user can just enter filename.txt or you can simply append a desired file extension to the string. CPP / C++ / C Code:
:davis: |
Recent GIDBlog
Toyota - 2008 November Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 08:44 |
| empty output file | Marjolein | C++ Forum | 8 | 17-Sep-2004 10:10 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| using vector or array | oshiotse | C++ Forum | 4 | 16-Apr-2004 11:59 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The