Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

DOS Help for Beginner

amanproamanpro Posts: 1Member
Hi Guys,

I hope you can help, I have a file and within that file I have about 20 odd lines of information, what I basically want to do is copy the first bit of information and ouput it to another text file so for e.g.

\blahlahlah.pj ->
\blah.pj ->
\blahlahlahlahlah.pj ->
\blah.pj ->

I want all the info from \ to -> ouputted to another file.

Thanks in advance for your help

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]
    1. Open the source file with fopen()
    2. Create the target file with fopen()

    3. Read source line with fgets()
    4. Find the marker where you need to truncate the line (strchr() or strstr())
    5. Truncate the line by storing zero AFTER the marker you have found
    6. Append '
    ' character to the line with strcat()
    7. Write the truncated line to target file with fputs()

    8. Repeat all steps starting from step #3 until there are no more lines left in source file.

    9. Close both files with fclose()
    [/color]
Sign In or Register to comment.