![]() |
|
#1
|
|||
|
|||
Issues using fstreamSo I'm trying to write a program that will read in a character from another file, and then test to see if it's a number, letter, operator, etc etc.
The file I'm getting my input from is a short program that uses a random number generator to output a random character each time it's run. I'm having trouble getting my character variable input into my actual program. Here's my RNG code: <character.cpp> CPP / C++ / C Code:
and here's my test program code: CPP / C++ / C Code:
x is obviously the variable I'm trying to get from character.cpp, but the cout line for some reason won't output anything, the only output I get is my assignment header and 'The file is open'. What is it I'm doing wrong? I've never used fstream before so... Thank you |
|||
|
#2
|
|||
|
|||
Re: Issues using fstreamcharacter.cpp only writes one character to the screen (stdout) and NOT to a file, is that what you wanted ?
The second program opens the character.cpp and reads one char of that, not the output x. Here is an example of setting up a loop to write "count" number of characters to the screen and at the bottom I show how you can redirect that output to a file. CPP / C++ / C Code:
CPP / C++ / C Code:
Code:
|
|
#3
|
|||
|
|||
Re: Issues using fstreamAh, thank you. That worked quite well.
And to answer your question, ShowHeader was a function that was required for me to put it, that was simply three cout commands that put my name, date, etc. at the top of the programs output. |
Recent GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is this how our leaders fix nation's most important issues? | poppyyo8 | Open Discussion Forum | 1 | 24-Mar-2008 09:13 |
| Windows Updates and Secure Website Issues | LocalTech | Computer Software Forum - Windows | 0 | 31-Jul-2007 04:30 |
| Graphics Issues (Screenshots Included) | NovaTiger | Computer Hardware Forum | 2 | 03-Apr-2007 17:16 |
| fstream problem | Xanathos | C++ Forum | 3 | 23-Nov-2006 17:59 |
| Downloadable document compatibilty issues? | rhino1616 | Web Design Forum | 3 | 07-May-2003 03:05 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The