MS-DOS

Moderators: blip
Number of threads: 362
Number of posts: 872

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
DOS Help for Beginner Posted by amanpro on 9 Sept 2010 at 12:58 AM
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.

\\blah\blah\blah.pj ->
\\blah.pj ->
\\blah\blah\blah\blah\blah.pj ->
\\blah.pj ->

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

Thanks in advance for your help
Report
Re: DOS Help for Beginner Posted by AsmGuru62 on 10 Sept 2010 at 4:46 AM

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 '\n' 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()



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.