Find/Replace with char arrays without string functions

Discussion in 'C++' started by Dmitridj@gmail.com, Nov 4, 2006.

  1. Guest

    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;
    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, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John_Woo
    Replies:
    4
    Views:
    669
    shakah
    Jul 6, 2006
  2. Brian Blais
    Replies:
    1
    Views:
    387
    Bruno Desthuilliers
    Jun 27, 2006
  3. Greg Ewing
    Replies:
    2
    Views:
    352
    Dieter Maurer
    Jun 29, 2006
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,070
    Ian Collins
    May 9, 2006
  5. Philipp
    Replies:
    21
    Views:
    1,139
    Philipp
    Jan 20, 2009
Loading...

Share This Page