1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice


Discussion in 'C' started by maustelistu, Feb 2, 2012.

  1. maustelistu

    maustelistu New Member

    Can someone help me?

    There is a text file. Make a C application in which you type a string, which counts the number of times the string is contained in the text file and print it on the display. Make a new text file which has the initial text file content but in which it is eliminated the string typed at the beggining.

    Sorry for my english, I'm not quite good at it.
  2. xpi0t0s

    xpi0t0s Mentor

    How far have you got and where are you stuck?
    Do you understand the requirements?
    What algorithm do you think you might use (as in: how do you think the program will work)?
  3. maustelistu

    maustelistu New Member

    Well... I'm stuck at ... Making the function to search the string inside the file and printing into another file the whole text eliminating the string
  4. xpi0t0s

    xpi0t0s Mentor

    OK. I get the feeling you want me to write it for you. That's not going to happen, so if that's what you want, this conversation ends here. I'll help you write it, but that's all. It's not up to me to do your homework for you.

    Let's start with something simple. Do you know how to create a function that will search inside a file for a string? This will involve opening a file and reading characters from it. Get that working, then move onto the next step.

    Maybe I'm jumping to the wrong conclusion. A very common beginner mistake is to try to write the whole program at one go, much like you would write an essay, and simply be overawed by it. For some reason teachers don't tend to teach an incremental approach. Let me let you into a secret: most code is written incrementally: that is, we start with a "hello world" program, then add a small amount of functionality to it and make sure that works, befor adding another bit of functionality, and so on until the program is complete. So in this case your first bit of functionality might be to open the file, read the characters in it and display them to screen, or send them to another file. Having created the stream, you then add the code to locate the desired string within the stream, and maybe print something like "Got it!" on the screen. Then debug the string finding code. Finally modify the program to remove that string from the stream and it's done.
  5. Scripting

    Scripting John Hoder

    Nicely said. :D

Share This Page