Search and replace coding....

This is a discussion on Search and replace coding.... within the C++ Programming forums, part of the General Programming Boards category; Thanks in advance for any help guys. This is a GREAT board to learn things from. I am looking to ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    6

    Talking Search and replace coding....

    Thanks in advance for any help guys. This is a GREAT board to learn things from. I am looking to make a program that takes multiple pictures, and add them to multiple web pages randomly.

    I want to use the fstream object to read the html file( a template), and have some flag in the html file be replaced with a picture location, and then write the html file to a predetirmined destination file.

    Essentially, all I need to know is if anyone has any idea how to scan a file for the flag to replace.

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    6
    up

  3. #3
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    fstream components...


    ...

    fstream outs;

    while (!outs.eof())
    {
    outs.get(character);
    if (character == control_character)
    {
    ...perform desired operations
    } // end if
    } // endl while

    ....
    Blue

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    6
    Thanks man, I'll give it a whirl.

  5. #5
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    *.put(char) writes to a file and increments the cursor. So you use *.get(char) to step you through the file character by character searching for your control character (or several control characters with embedded 'if' statements). Once you find what you need, you *.put() whatever you want to put into the file. I am not sure that .put() will take an array as an arguement. If such was the case you could use a null terminated array to output a string. It is possible to step through the array yourself as well and loop the .put() statment so that each character is placed anyway.... good luck
    Blue

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    6

    Cool

    Just so ya know. That worked GREAT man! Thanks for the help. You are a lifesaver.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. vector search and replace
    By rahulsk1947 in forum C++ Programming
    Replies: 6
    Last Post: 06-04-2009, 10:13 PM
  2. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  3. Search and Replace
    By sh0rty in forum C++ Programming
    Replies: 4
    Last Post: 12-26-2002, 03:26 PM
  4. IDEA: Search And Replace
    By ygfperson in forum Contests Board
    Replies: 1
    Last Post: 08-13-2002, 12:28 AM
  5. open file, search of word, replace word with another
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 06-05-2002, 02:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21