Library code snippets
[C++] Simple Multiplication Test - Involves with : files & strings & arrays & ...
By Mohammad Rastkar, published on 07 May 2007
Page 5 of 5
- About The Program
- Lettered_Numbers.cpp
- Class_List_Manipulation.cpp
- Download Files
- Note About Retrieving a File
Note About Retrieving a File
=> If you want to retrieve a file (that contains more than one line or one line but with spaces), you can use the following code snippet :
=======================================
fstream fs( "file.dat", ios::in );
string file; // saves the file
char ch[81];
while (!fs.eof())
{
fs.clear(ios::goodbit); // each time 'getline()' gets a line, you should call 'clear', if not, getline always gets NULL
fs.getline(ch, 81);
file += ch;
// if (!fs.fail() && !fs.eof()) // indicates the end of a line
// ;
}
fs.close();
============================================
Related articles
Related discussion
-
Convert C++ code to VB6
by mawcot (4 replies)
-
How to create a games like FIFA08
by mawcot (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Seeking developers for Montreal Office
by mazen_kt (1 replies)
-
Is there anyone here willing to be interviewed regarding their career in IT?
by krizs (1 replies)
This thread is for discussions of [C++] Lettered_Numbers : Simple Multiplication Test, that involves with : files & strings & arrayes & ....