Just say i want to read a amount of words, lines, and characters in a .dat file. Im thinking my string algoritim would look something like this:
------------------------------------------
//for words, lines, characters count read file, and then out_stream or cout results
//in_stream is already connected to words.dat
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
int words, lines, characters;
ifstream in_stream;
ofstream out_stream;
while(!in_stream.eof())
{
//chracter readout, and cout result
characters = strlen("words.dat");
out_stream << "words.dat has " << characters << " characters.";
//lines readout, and cout result
//words readout, and cout result
}
I cant think of an algoritum for lines, and words. I do have idea of lines, i think its something like this "\n" , line++ . I think words is something like this "\0" word++ . The thing is, i can't translate it into code form, do I use strlen(), or getline()??? Please help, or suggestion...Thank You!