#include <iostream>
#include <fstream>
#include <cstring>
#define MAX_CHARS_PER_LINE 512
#define MAX_TOKENS_PER_LINE 20
#define DELIMITER " "
using namespace std;
int main ()
{
//char buf[MAX_CHARS_PER_LINE];
string buf; // string to store a line in file
fstream fin;
ofstream fout;
fin.open("PiCalculator.h", ios::in);
fout.open("op1.txt", ios::out);
fout<< "#include \"PiCalculator.h\"\n";
static int flag=0; //this variable counts the no of curly brackets
while (!fin.eof())
{
// read an entire line into memory
getline(fin, buf);
//fout<<buf.back()<<endl;
if(buf.back()== "{" && buf.front() !='c'){
flag++;
fout<<buf<<endl;
}
if(flag > 0)
fout<<buf<<endl;
if(buf.back()== "}"){
flag--;
fout<<buf<<endl;
}
}
cout<<buf.back()<<endl;
return 0;
}
Here I'm getting the error in the if condition:
if(buf.back()== "{" && buf.front() !='c')
The error states that: ISO C++ forbids comparison between pointer and integer [-fpermissive]
Can anyone help me in sorting out the problem ??