LinuxQuestions.org
Register a domain and help support LQ
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 05-10-2013, 08:57 AM   #1
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 178

Rep: Reputation: Disabled
Unhappy creating log file with rw+a then also contains i am sending to file are not appnded


fp = fopen ("/home/ivb/rohan/files/log/desc_log.txt", "rw+a");

if(fp){
printf("log is created. . .\n");
}
else{
printf("error in creating log. . .\n");
er=1;
}
1. when i run the code at first run it doest create file with "rw+a"
2. i have to go n change it to w+ mode n run the code again then file gets created.
3. "rw + a" mode gives file creation error if i run it first time
4. appending the data doesnt really occures

whre i am making the mistake please give suggstion

Thanks & Regards
rohaan
 
Old 05-11-2013, 06:47 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
fopen("blah", "a");
for appending.


man fopen

a Open for appending (writing at end of file). The file is created if
it does not exist. The stream is positioned at the end of the file.
 
1 members found this post helpful.
Old 05-11-2013, 07:17 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,947

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
Note: mode="a" (or O_APPEND with open) doesn't simply mean 'seek to the EOF after open', instead it means 'seek to the EOF before each write' -- that's how multiple processes can use the same log-file
 
  


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
Creating a Log file to log activity time in Ubuntu mint nervous137 Linux - Newbie 4 04-19-2012 08:37 AM
[SOLVED] Sending Errors to Log File: Best Practice? blingham Linux - Newbie 3 07-24-2009 08:59 AM
creating a log file of users who are missing a file gd121462 Linux - Newbie 5 12-04-2008 04:54 AM
creating log file RudraB Programming 2 12-13-2007 12:35 AM
Creating the log-file dr_sad Programming 5 04-12-2005 06:01 PM


All times are GMT -5. The time now is 04:42 AM.

Main Menu
Advertisement
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