Solved

Edit Files (Read/Write)

Posted on 2006-06-23
1
203 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
ID: 16969265
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C: GetDiskFreeSpaceEx() for default drive 14 114
Why adding test code changes the build ? 11 132
How to set environment variables in C 2 86
C#, VS15, StructLayout 1 135
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

830 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