By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,388 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,388 IT Pros & Developers. It's quick & easy.

Find/Replace with char arrays without string functions

P: n/a
Heya everyone,

I'm trying to write a program that finds and replace an array of
characters defined by the user in a text file. Basicly the program
finds and replaces a substring typed in by the user. I've got the
opening file and displaying its contents down, but the problem is, I
can not use any of the string member functions to find and replace. I
am trying to read a line of text from the input file at a time and
comparing it to what the user typed in. All I got so far is the
following code segment that only finds a character:

ifstream inFile;
const int i = 11;
char find[i];
const int j = 81;
char input[j];
char ch;
int count = 0;

inFile.getline(input,j);
inFile.get(ch);
while(!inFile.eof())
{

while(ch != '\n')
{
if(find[i-11] == ch)
count++;
inFile.get(ch);

}
inFile.getline(input,j);
}

Any help would be greatly appreciated!!

Thank you
Dmitridj

Nov 4 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.