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. Advertisements

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. wwj
    Replies:
    7
    Views:
    793
  2. Bill Reyn
    Replies:
    3
    Views:
    2,714
    Bob Hairgrove
    Jun 22, 2004
  3. John_Woo
    Replies:
    4
    Views:
    776
    shakah
    Jul 6, 2006
  4. Brian Blais
    Replies:
    1
    Views:
    571
    Bruno Desthuilliers
    Jun 27, 2006
  5. Greg Ewing
    Replies:
    2
    Views:
    524
    Dieter Maurer
    Jun 29, 2006
  6. lovecreatesbeauty
    Replies:
    1
    Views:
    1,408
    Ian Collins
    May 9, 2006
  7. arnuld
    Replies:
    19
    Views:
    924
    Jacek Dziedzic
    Mar 30, 2007
  8. Philipp
    Replies:
    21
    Views:
    1,502
    Philipp
    Jan 20, 2009
Loading...