Sorry guys, I got the answer that I was looking for. Instead of pressing return after each >> just use a space until the last input like:
x [space] x [space] x [space] x {enter]
and it will...
Type: Posts; User: Therry
Sorry guys, I got the answer that I was looking for. Instead of pressing return after each >> just use a space until the last input like:
x [space] x [space] x [space] x {enter]
and it will...
OK, I commented out the troubling
if (! d_file )
{
cout << "Can't open input file " << endl << endl;
cin.get();
exit(1);
}
I understand that
if (! d_file ) { cout << "Can't open input file " << endl << endl; cin.get(); exit(1); }
only checks to see if the file is opened by:
Sorry, but it is you who have missed the point of my question. I know that the standard way of a cin is always with a new line. What I'm asking is there a way to override the '/n' in the output by...
Independent of the instruction, if I code
cin >> aa >> bb >> cc >> dd; It is the same as
cin >> aa;
cin >> bb;
cin >> cc;
cin >> dd;
I'm sorry about being so thick here, but I do not understand your question? The code that you quoted is the new data that I wish to write/append into the file. Are you implying that I should use...
There seems to be a misunderstand here. I did not ask how to read the statement into code. I already coded the statement.
cin >> aa >> bb >> cc >> dd;in my program and it worked just fine. I asked...
Sorry, that did not work. It is true that the addition of * std::ios::app* caused the program to stop erasing the content of the file, but the file is still not up-dated with the new data. What am I...
How does one get more than one *cin >>* statements to write out on the same line?
I want it written as
"x x x x MB x" instead of:
x
x
x
x
MB
Thanks nimitzhunter http://im.cprogramming.com/images/statusicon/user-online.png, That's what I needed. I forgot that.
Thanks. I am opening the file to write the numbers with the highest frequencies, then reopening the file to write the numbers having the lowest frequencies. I was tole that I have to close the file...
The following code worked just fine.
ofstream d_file ( "D:\\1_LotteryPrograms\\1_Fla_Mega_Money\\High_Freq.txt" );
if (! d_file )
{
cout << "Can't open input file " << endl << endl;
Sorry to revisit this subject, but I have another question with I/O files. Do I need to have both *ifstream* & *ofstream* statements in order to reopen a file? The first part worked just fine, but...
Hi all,
My next project in my self-teaching of C++ is sorting programs. I have chosen -- Selection sort -- as my teaching device.
I've chosen this code for a simple selection sort because I...
WOW!. . . . Thanks for your patience!
Are you saying that I must close the file "Highest_Frequencies.txt" each time I've finished writing to it?
Is that the only safe way to recall/reopen the file to append it?
I did not know this. I...
I took your suggestion and replaced both:
ofstream f_file ( "D:\\1_LotteryPrograms\\1_Fla_Mega_Money\\Highest_Frequencies.txt" );
ofstream out1;...
My code is:
ifstream e_file ( "D:\\1_LotteryPrograms\\1_Fla_Mega_Money\\Highest_Frequencies.txt" );
if (!e_file )
{
cout << "Can't open input file" << " Highest_Frequencies.txt " << endl <<...
Sorry, this newbie is really slow when it comes to C++.
Are you suggesting that I replace line 8 with lines 10 & 11?
// will probably fail because the file is already open
It's does me no good it it fails, how can I do it so that is does not fail?
Sorry to be such a dummy, but exactly where would you put:
ofstream out1;
out1.open("D:\\1_LotteryPrograms\\1_Fla_Mega_Money\\Highest_Frequencies.txt", std::ios::app);
to append my file? My...
Hi all
I have a different problem now -- trying to use "ios::app".
I understand it is what you use to append to a file, but where is it placed?
in
ifstream a_file ios::app?
in
ofstream...
WoW, thanks. I got it working! Thanks everyone.
Sorry to be such a dunce, I'm not sure I understand. Could you give ma an example?
I changed it like this:
// displays 1st, 2nd, 3rd, and 4th highest frequencies
cout << indexoffirst << " = "<< first << endl << endl;
cout << indexofsecond << " = " <<...