Thread: freopen and strings

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    6

    freopen and strings help plz

    hi guys, new here...seems like a very helpful site...

    so on with the question.

    I was asked to write a program using the argc and argv cmd line arguments and also freopen.

    here is what is has to do

    3 txt files are the cmd line arguments

    using the str commands, I have to somehow search through one txt file which is a written paragraph looking for a <tag1> then a <tag2> and then replace them with what is in the secon text file whick looks like this:
    <tag1> example1
    <tag2> example2

    of course I cannot show the tags, only the example when replace which is written to the 3rd txt file.

    I get the cmd line and freopen stuff no prob, I am just very very weak with strings.

    please help
    Last edited by Juicehead; 11-20-2002 at 08:44 PM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    freopen() eh? Personally I'd use fopen()... but its your choice.

    As for the strings, you're about to learn a lot about char array manipulation. Try looking up strstr() to start with.

    Also, you'll need a 2-d array to hold the words from the tag list file (or a hashtable, list or tree).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    6
    if I am getting the tags from argv[1] and they are listed exactly like this in the txt file

    <tag1> example1
    <tag2> example2
    <tag3> example3
    <tag4> example4

    how does the program know where to go after the first line and not to print what is in the <>.

    thx

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    6
    ok, I got the form loaded into a 2d array, now I need to get the need to get the tags.txt file loaded into a parallel array

    <tag1> example1
    <tag2> example2
    <tag3> example3
    <tag4> example4

    one array needs to hold tags, the other needs to hold example...

    I did a

    scanf("%10s[^/n]", the_tags) for the tag array

    but it will not stop at the >


    arrrgh

    thx much for the help so far guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-01-2002, 07:50 AM