Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Edit Files (Read/Write)

Posted on 2006-06-23
1
Medium Priority
?
209 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-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 30

Accepted Solution

by:
Axter earned 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 opening and writing to files 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.

618 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