This is what I am doing:Originally Posted by dwks
// open the file to read in the text
ifstream file;
file.open(TEXTFILE);
Thanks.
This is what I am doing:Originally Posted by dwks
// open the file to read in the text
ifstream file;
file.open(TEXTFILE);
Thanks.
See Daved's post if you're using a string.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Yes, its working now.
I am seperating everything into working functions as my next step.
After that I will transfer the output to a file. The ouput being a grid doesn't seem to tough to manage.
Also, I would like to be able to output the found searchwords in color in order to highlight them for the user. How do I change the color of the text being outputed to a file?
Thanks.
Its working now as output to a file. I am not sure how to output in color text though.
Thanks.
How do I set the character it stops reading at? It is stopping at /n right now, but I wanted it to read the whole file all the way through.
Thanks.
Could I use the ignore()? How do I ignore all of the say spaces or /n characters and just read in all of the text characters in file?
Thanks.
To read the entire contents of a file into a string, you could use getline in a loop, or you can use a stringstream like this example (important parts bolded):Code:#include <iostream> #include <fstream> #include <sstream> #include <string> int main() { std::ifstream ifs("input.txt"); std::stringstream sstr; sstr << ifs.rdbuf(); std::string file_contents = sstr.str(); std::cout << file_contents; }
Thanks, it works now with this method. I was trying get a minute ago and it inserted extra characters.Originally Posted by Daved
Now to finish seperating into functions and alow for simultaneously allowing for multiple searches with different skips.
Also, does anyone have a solution to outputing in colored text? I can't find anything on outputing to a file using colored text.
Thanks.
You cannot output colored text in simple text files. To make it colored in the console, you need special console based commands that depend on your platform. Check out adrianxw's tutorial for information on that. To make a file have colored text, you'll have to write out the data in a special format like rtf. That's a lot more advanced than your current code seems to be ready for, but you can look into it by looking up the Rich Text file format.
Yes, how do I go about outputing RTF? Is there an article on it?Originally Posted by Daved
Thanks.
I'm sure there are a bunch, although probably not at this site. Did you search for one? It's way too complicated for me to describe here, even if I knew the syntax.
I think it might be better if I simply transfered my program into windows first.Originally Posted by Daved
I have programmed in WIN32 before, but it has been a while.
Any suggestions on what I might use as the lay out for the program?
Thanks.