Okay, I’ve encountered another problem with my simple program. My program gets the text file, reads it, then deletes the last symbol and outputs the new text file with the changes. It does everything as I want except that it does delete all spaces. Any solutions for that?
Here’s the code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char symbols[10000];
ofstream outFile("outFile.out");
ifstream inFile("inFile.in");
for(int i=0;i<10000;i++)
{
inFile >> symbols[i];
}
for(int j=0;j<10000;j++)
{
if(symbols[j]=='\0')
{
symbols[j-1] ='\0';
break;
}
}
if(outFile.is_open())
{
for(int l=0;l<10000;l++)
{
outFile << symbols[l];
}
}
inFile.close();
outFile.close();
return 0;
}
P.S.
I mean if I give it a text with
Hello world
it outputs Helloworl
the spaces magically disappear..
Use
There is a manipulator too, if you include
iomanip: