Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Find/Replace with char arrays without string functions

Reply
Thread Tools

Find/Replace with char arrays without string functions

 
 
Dmitridj@gmail.com
Guest
Posts: n/a
 
      11-04-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
confused between char and char* and connection to Arrays arnuld C++ 19 03-30-2007 04:42 AM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
char arrays and integer arrays... why the difference? Bill Reyn C++ 3 06-22-2004 12:01 PM



Advertisments