I have a text file with a paragraph of text in it, but in between each letter is a space. I'm trying to get a program to read into the file and write a file with no spaces, but I'm not managing. I've tried something like this so far ( this isn't the actual code, I get frustrated and deleted it :P )
Then I come across a problem. "data" wasn't declared as an array, so I can't use this :Code:int main() { ifstream fin; ofstream fout; fin.open("myfile.txt", ios::binary | ios::in); if(!fin) { cout << "File not opened."; Sleep(2000); return 0; } char data; while(fin.get(data)) { cout << data; } /* Up to here, my program works, and I get everything printed to screen. */
Also, I can't do this :Code:for(int x = 0; x < strlen(data); x++) { cout << data[x] x++; }
Does anyone see how I could solve this ?Code:char content[strlen(data)] = data; for(int x = 0; x < strlen(data); x++) { cout << content[x] x++; }
Thanks.



LinkBack URL
About LinkBacks


