I am wondering how can i erase white space.
If program read data from source file then write it on the target file. If there are leading and trailing white-space in the source file but should be discarded for the destination file.
I am wondering how can i erase white space.
If program read data from source file then write it on the target file. If there are leading and trailing white-space in the source file but should be discarded for the destination file.
I'm doing something similar. You'll have to build ur write string one character at a time. Use two counters. If you see double/reoccuring spaces, you just skip to the next character in the read string, but maintain the same position in the write string.
When you write a character into the new string, increase the second counter.
Hope that helped.
Try:This is taking in every char x; and checking for spaces.Code://Open a stream ifstream file; //Open file file.open("file.txt", ios::in); //Read data while(!file.eof()) { file.get(x); //Get the data by char if(x==' ') //x is a space { //Do nothing } else { //handle file } }
C++ Is Powerful
I use C++
There fore I am Powerful