LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-16-2006, 07:25 AM   #1
cigarstub
Member
 
Registered: Sep 2005
Posts: 145

Rep: Reputation: 15
I really can't do this w/out ur sample code in C nature language, please help me writ


I really do not know the optimy way dealing w/ "editing a file"
how to open ? Is it fopen("a pointer", "the filename")
to write n save immediatr ? is it append("a string","to the file") then Must I close the file to save the change or no need since I do not want this method
how to go to a specific line in txt file ?
how to return to the previous line after appending ?
Could u write me a sample code doing all these ?
 
Old 02-16-2006, 07:30 AM   #2
kshkid
Member
 
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383

Rep: Reputation: 30
Quote:
Originally Posted by cigarstub
I really do not know the optimy way dealing w/ "editing a file"
how to open ? Is it fopen("a pointer", "the filename")
to write n save immediatr ? is it append("a string","to the file") then Must I close the file to save the change or no need since I do not want this method
how to go to a specific line in txt file ?
how to return to the previous line after appending ?
Could u write me a sample code doing all these ?
yes, it is fopen (or) open to a file
to write and save immediately fwrite and flush it
if you are using write no need to flush it
if you close the file; implicitly contents in file buffer would be flushed and stored
to go specific line -> fseek

check man pages for all the system calls
 
Old 02-16-2006, 07:31 AM   #3
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 58
simple answer: No. we wont do your assignments for you.

long answer:
your on the basic right track. you will need fopen and fclose.. and a combination of fwrite/fread or fputc/fgetc

read here note the links at the very bottom of the page
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system() and execl anyone got any sample code please? twirl Programming 2 09-08-2005 02:01 AM
Using sample C++ code from a book...won't compile Baix Programming 4 03-05-2005 02:04 PM
Perl: What's this mean? (Code sample) Benr Programming 5 10-23-2004 07:20 AM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 11:16 AM
Any sample code of how to use Rand_seed() cybercop12us Programming 0 04-03-2003 07:25 AM


All times are GMT -5. The time now is 09:26 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration