473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to use the open() call

pal
Hi,

How to use the open() ( mean syntax ) to open a file and to append the
data every time at the end of the file.
My Problem is,

I created a file and written some data into it, and second time i
opened the file with the open() like
fd = open ("\dir\file.dat",O_WRONLY,0); and written some data into
this file.

But always I am not able to append the data to the file.instead it is
overwriting the file.
Is there any way to solve this problem .
Thanks.
Aug 19 '08 #1
7 3507
pal wrote:
Hi,

How to use the open() ( mean syntax ) to open a file and to append the
data every time at the end of the file.
Unfortunately, open() is not a standard C call, and its meaning, syntax,
and attendant issues are determined by the implementation that you are
using. It is likely that that is a Unix-like one, in which case a Unix
(or Posix or Linux) newsgroup is the right one. The usual Posix/Unix
open() yields an int called a file-descriptor, which is not the way
streams are referenced in the standard C library. There the similar
call is fopen() which yields pointer-to-FILE. If you have trouble using
the standard C functions, this is the place. If your problem is with an
implementation-specific function like open(), this is not the place for it.
Aug 19 '08 #2
On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
How to use the open() ( mean syntax ) to open a file and to append the
data every time at the end of the file.
RTFM: man 2 open

Look for the bit about O_APPEND.

Aug 19 '08 #3
On Aug 19, 3:01 pm, viza <tom.v...@gm-il.com.obviouschange.invalid>
wrote:
On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
How to use the open() ( mean syntax ) to open a file and to append the
data every time at the end of the file.

RTFM: man 2 open

Look for the bit about O_APPEND.
Off-topic in comp.lang.c
It would be more appropriate in comp.unix.programmer where the POSIX
standard is topical.
Aug 19 '08 #4
On Tue, 19 Aug 2008 16:54:06 -0700, vippstar wrote:
On Aug 19, 3:01 pm, viza wrote:
>On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
>>How to use the open() ( mean syntax ) to open a file and to append
>Look for the bit about O_APPEND.
Off-topic in comp.lang.c
http://biblecc.com/luke/6-9.htm
Aug 20 '08 #5
viza said:
On Tue, 19 Aug 2008 16:54:06 -0700, vippstar wrote:
>On Aug 19, 3:01 pm, viza wrote:
>>On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
>>>How to use the open() ( mean syntax ) to open a file and to append
>>Look for the bit about O_APPEND.
>Off-topic in comp.lang.c

http://biblecc.com/luke/6-9.htm
Not really applicable - vippstar gave an appropriate redirection with the
intent of getting *better* help for the OP.

If someone asks for a newspaper in the butcher's shop, the shopkeeper who
reaches under the counter and pulls out a grease-spotted newspaper dating
back two weeks and with the Sudoku already half-filled in is not
performing as great a service as the shopkeeper who redirects the enquirer
next door to the newsagent.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 20 '08 #6
On Aug 20, 7:35*am, Richard Heathfield <r...@see.sig.invalidwrote:
viza said:
On Tue, 19 Aug 2008 16:54:06 -0700, vippstar wrote:
On Aug 19, 3:01 pm, viza wrote:
On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
>>How to use the open() ( mean syntax ) to open a file and to append
>Look for the bit about O_APPEND.
Off-topic in comp.lang.c
http://biblecc.com/luke/6-9.htm

Not really applicable - vippstar gave an appropriate redirection with the
intent of getting *better* help for the OP.

If someone asks for a newspaper in the butcher's shop, the shopkeeper who
reaches under the counter and pulls out a grease-spotted newspaper dating
back two weeks and with the Sudoku already half-filled in is not
performing as great a service as the shopkeeper who redirects the enquirer
next door to the newsagent.
<OT>
Geeze, a while back I made a similar comment to another person.
Shortly after that, I got all these snide responses.
</OT>
Aug 20 '08 #7
Chad said:
On Aug 20, 7:35 am, Richard Heathfield <r...@see.sig.invalidwrote:
<snip>
>vippstar gave an appropriate redirection with
the intent of getting *better* help for the OP.

If someone asks for a newspaper in the butcher's shop, the shopkeeper
who reaches under the counter and pulls out a grease-spotted newspaper
dating back two weeks and with the Sudoku already half-filled in is not
performing as great a service as the shopkeeper who redirects the
enquirer next door to the newsagent.

<OT>
Geeze, a while back I made a similar comment to another person.
Shortly after that, I got all these snide responses.
</OT>
Fear not. I'm sure some snide responses are winging their way to me even as
I write this.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 20 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lukeo | last post by:
I'm shelling out to an .asp (or htm) page from an application. I want to show this in a window without the address bar, etc... Is there a way I can redirect this page using javascript to a page...
10
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#"...
1
by: ian.michel | last post by:
I have a parent window that pushes a new window object onto an Array with the following code : OpenChild() { //totalNumWindowsCreated is global totalNumWindowsCreated =...
4
by: jadiyo | last post by:
Hi, I've read many questions about how to automatically open a new window from a page using the JavaScript onLoad command. Unfortunately, due to the web application framework being used...
9
by: Charles F McDevitt | last post by:
I'm trying to upgrade some old code that used old iostreams. At one place in the code, I have a path/filename in a wchar_t string (unicode utf-16). I need to open an ifstream to that file. ...
13
by: tochiromifune | last post by:
Hello The window.open method brings my window to the top only if it is new. If it's being reused, the window does not come to the foreground (with IE 6 it does). Is there a new way in...
1
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access...
7
by: (PeteCresswell) | last post by:
I've got a UNC. It's something like H:\CDL\Attachments\Deal000023.InitialOffering.doc. I want to feed that UNC to MS Windows and let Windows worry about selecting which application to use to...
1
by: Charlie | last post by:
I am trying to make an XMLHttpRequest which violates the default "same- origin"policy in Firefox. I checked the archives and found a method that should work but it does not. Below is the test code...
5
by: Stefano Tonello | last post by:
Hi all, I need to call windows' "open with" dialog from my C# windows form application. After the user selects application, control must return to me (I have to launch directly the process). I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.