Solved

Edit Files (Read/Write)

Posted on 2006-06-23
1
200 Views
Last Modified: 2010-04-15
Ok this should be simple, but I have no idea where to start on this.

I need to make an application to read a text file line by line and then edit one line, and save the file.
It needs to work for Unix/Linux, not Win32.

Can someone point me to what functions or little example code, thanks.
0
Comment
Question by:-Karamja-
1 Comment
 
LVL 30

Accepted Solution

by:
Axter earned 125 total points
Comment Utility
Hi -Karamja-,
You can use fopen to open the file, and fgets to read line by line.
To modify a file, it's usually better to write the modified version to a temporary file, and once you're done, close both files, and copy the temp file to the target file.  Then delete the temp file.

David Maisonave (Axter)
Cheers!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
why debugging a macro i s difficult 10 26
Way to improve it 16 59
Need example 5 100
An API detour question 7 65
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now