ندانستم چیکار کردی ولی اینطوری ببین همان خاسته شما میشه.
void rew(){
int m=0,flag=0, c;
char a[256+1],ch;
ifstream infile ("text.txt", ios_base::in);
ofstream outfile("neshane.txt", ios_base::out );
infile.getline(a,256);
while(a[0]!=0){
for(int i=0;i<256;i++)
{
int c=a[i];
if(flag==1){
while(a[i]!='*' && a[i+1]!='/')
i++;
i--;
flag=0;
}
if((c>=65 && c<=90)|| (c>=96 && c<=122)){ // the range of asci code for lower case and upper case alphabet.
outfile.put(a[i]);
m=1; // the current character is an alphbet.
}
if((c>=48 && c<=57)){ // the range of asci code for numbers(0-9).
outfile.put(a[i]);
m=2; // the current character is a number.
}
switch(c){
case 58: // the asci code for ":" character.
if(m==1 || m==2 || m==4){
outfile.put('\n');
outfile.put(a[i]);
if(a[i+1]=='='){
outfile.put(a[i+1]);
i++;
}
m=3; // the current character is not a number or an alphabet.
outfile.put('\n');
}
else {
cout<<"ERROR";
// exit(-1);
}
break;
case 40: // the asci code for "(" sign.
case 41: // the asci code for ")" sign.
case 43: // the asci code for "+" sign.
case 45: // the asci code for "-" sign.
case 61: // the asci code for "=" sign.
if(m==1 || m==2 || m==4){
outfile.put('\n');
outfile.put(a[i]);
m=3;
outfile.put('\n');
}
else{
cout<<"ERROR";
//exit(-1);
}
break;
case 62: // the asci code for ">"sign.
if(m==1 || m==2 || m==4){
outfile.put('\n');
outfile.put(a[i]);
if(a[i+1]=='='){
outfile.put(a[i+1]);
i++;
}
m=3;
outfile.put('\n');
}
else{
cout<<"ERROR";
//exit(-1);
}
break;
case 60: // the asci code for "<" sign.
if(m==1 || m==2 || m==4){
outfile.put('\n');
outfile.put(a[i]);
if(a[i+1]== '='){
outfile.put(a[i+1]);
i++;
}
m=3;
outfile.put('\n');
}
else{
cout<<"ERROR";
//exit(-1);
}
break;
case 42: // the asci code for "*" sign.
if(m==1 || m==2 || m==4){
outfile.put('\n');
outfile.put(a[i]);
if(a[i+1]=='/'){ // the end of comments.
outfile.put(a[i+1]);
i++;
}
m=3;
outfile.put('\n');
}
else{
cout<<"ERROR";
// exit(-1);
}
break;
case 47: // the asci code for "/" sign.
if(m==1 || m==2 || m==4){
outfile.put('\n');
outfile.put(a[i]);
if(a[i+1]=='*'){
flag=1;
outfile.put(a[i+1]);
i++;
}
m=3;
outfile.put('\n');
}else{
cout<<"ERROR";
//exit(-1);
}
break;
case 32: // the asci code for space.
outfile.put('\n');
m=4;
break;
default:
break;
}
}
infile.getline(a,256);
}
}