How could I make a program read a file line-by-line? Not string-by-sting; line-by-line.
How could I make a program read a file line-by-line? Not string-by-sting; line-by-line.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
you wanna make a progam that reads a complete line into a string, i mean until end of lineOriginally posted by CodeMonkey
How could I make a program read a file line-by-line? Not string-by-sting; line-by-line.
then you should use:
i'm not sure about the arguments order, i mean, i used fgets but dont know if thats the right orderCode:FILE *inp=fopen("input.dat","rt"); char s[200][202]; int k=0; while(!feof(inp)){ fgets(s[k],inp,200); k++; }
i used fgets(destination, sourcefile, maxlenght);
you should check the help for getting the correct order
Null Shinji The Sorcerer is here
Evangelion Quotes:
"If youre gonna do it, dont waste time. Otherwise, leave", Gendo
"Release the final safety lock, Evangelion Unit One, Lift Off!!", Misato
"Syncrograph has reversed, pulses are flowing back!!!", Maya
streamload id= nullshinji icq= 12944337; E-M@IL= [email protected]; aim= mayeba
msn= [email protected]
// reading a text file
#include <iostream.h>
#include <fstream.h> //input with files
int main () {
char buffer[256];
ifstream examplefile ("example.txt"); //set file for reading.
if (! examplefile.is_open()) //error when opening file
{ cout << "Error opening file"; exit (1); }
while (! examplefile.eof() ) //while its not the end of file
{
examplefile.getline (buffer,100); //just like cin but from file
cout << buffer << endl;
}
return 0;
}
...