files in out

Goodevening everybody.
I have a problem like this, I want to write script that take word from first fail and put in other only in that case if there is 'm' letter, but my script only takes first word and I can't find my problem, can anybody help me?/

#include <iostream>
#include <fstream>
using namespace std;
const int size=10;
int main(){
char c;
int i=0, z=0;
char s[size];
fstream fin ("in.txt", ios::in);
fstream fout ("out.txt", ios::out);
fin.get(c);
while (!fin.eof()){
if (c==' ' or c==',' or c=='.' or c=='!' or c=='?' or c==':' or c=='(' or c==')')//nolasītais c ir pieturzīme
{
if (!fout.is_open()) fout.open("out", ios::out);
else {

fin.get(c);

}
} else
{
while (c!=' ' and c!=',' and c!='.' and c!='!' and c!='?' and c!=':' and c!='(' and c!=')' and !fin.eof()) //kamer nav pieturzīme
{
s[i]=c; // ieraksta masīvā
i++;

fin.get(c);
}
for (int k=0; k<i;k++){ if(s[k]=='m')

for (int m=0; m<i; m++) fout.put(s[m]);}

i=0;
fin.get(c);
}
fin.close();
fout.close();
return 0; };}
another problem, ok I solved my first stupid problem, but now he writes that many words how man 'm' letters are
Last edited on
Topic archived. No new replies allowed.