I just try to write a program in C++. I knew it is very easy. but I can't not figure out whai's wrong?
I want to read a very long string in a .txt file, and then split this string into many substrings (the length of each substring is 50).
My code like this:
using namespace std;
const char* filename="aa.txt";
cout<<endl<<"Failed to open file"<<filename;
That will only read in one word. The operator >> stops reading input when it encounters a whitespace, so n=ll/L may equal zero. What does your input file look like?
If i=0, j=1 and you start the substring at position 1, but the string index starts at 0. Is that what you want? If text.length() is 5, the indexing goes from 0-4.
Last edited by 7stud; 05-03-2003 at 09:08 PM.