I’ve encountered a problem. I have a code which should read the following text file, delete the last symbol and output the new text in other file. My problem would be: how to delete the last symbol? I’ve tried things like
for(int j=0;j<10000;j++)
{
if(simbols[j]=='\0')
{
cout<<j;
minusOne = j-1;
minusOne ='\0';
break;
}
}
But it doesn’t really help and do anything I want. Any help would be appreciated!
P.S.
If it would be any help here’s the full code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char simbols[10000]; int minusOne;
ofstream outFile("outFile.out");
ifstream inFile("inFile.in");
for(int i=0;i<10000;i++)
{
inFile >> simbols[i];
}
for(int j=0;j<10000;j++)
{
if(simbols[j]=='\0')
{
cout<<j;
minusOne = j-1;
minusOne ='\0';
break;
}
}
if(outFile.is_open())
{
for(int l=0;l<10000;l++)
{
outFile << simbols[l];
}
}
inFile.close();
outFile.close();
return 0;
}
It looks to me like you meant to put
instead of