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 |
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. |
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
|
All times are GMT -5. The time now is 09:23 AM. |