quietcoder
June 7th, 2002, 11:45 AM
im using dev-c++
how can detect if there are (user input) x number of characters in a row, in a text file?
current partaning code
# include <fstream.h>
void main()
{
ofstream fout;
ifstream fin;
fin.open("input.txt");
fout.open("output.txt");
char narowa, narowb, singlea, singleb;
int howmanynarowa, howmanynarowb;
cout<<"What character do you want for singlea?:";
cin>>singlea;
cout<<"What character do you want for singleb?:";
cin>>singleb;
cout<<"how many in a row do you want for narowa?:";
cin>>howmanynarowa;
cout<<"how many in a row do you want for narowb?:";
cin>>howmanynarowb;
cout<<"what character do you want for narowa?:";
cin>>narowa;
cout<<"what character do you want for narowb?:";
cin>>narowb;
while (!fin.eof())
{
/*get characters keeping them in the same order as orginal file*/
/*turning the characters in a row that match the users inputs*/
/*into one character that the user inputs*/
/*then out putting to a different file*/
}
fout << flush;
fout.close();
fin.close();
}
the only way i can think of is to use a counter
i don't know but im sure theres a specific function to count characters in a row
how can detect if there are (user input) x number of characters in a row, in a text file?
current partaning code
# include <fstream.h>
void main()
{
ofstream fout;
ifstream fin;
fin.open("input.txt");
fout.open("output.txt");
char narowa, narowb, singlea, singleb;
int howmanynarowa, howmanynarowb;
cout<<"What character do you want for singlea?:";
cin>>singlea;
cout<<"What character do you want for singleb?:";
cin>>singleb;
cout<<"how many in a row do you want for narowa?:";
cin>>howmanynarowa;
cout<<"how many in a row do you want for narowb?:";
cin>>howmanynarowb;
cout<<"what character do you want for narowa?:";
cin>>narowa;
cout<<"what character do you want for narowb?:";
cin>>narowb;
while (!fin.eof())
{
/*get characters keeping them in the same order as orginal file*/
/*turning the characters in a row that match the users inputs*/
/*into one character that the user inputs*/
/*then out putting to a different file*/
}
fout << flush;
fout.close();
fin.close();
}
the only way i can think of is to use a counter
i don't know but im sure theres a specific function to count characters in a row