473,326 Members | 2,127 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,326 software developers and data experts.

gcc. mkstemp works but I can't write to the new files.


I am obviously confused about how to write to the file created
by the mkstemp function.

The manual says that it returns a pointer to a file descripter
when successful and I think that the function is working right because
I get the randomized name in the text string and the function does
return an integer value as well as leaving a new file of the same
name.

What I haven't been able to do is write to it.

I have tried capturing that number in an int variable which
works fine, but putting that variable name in the fprintf statement
causes a segmentation fault.

I tried capturing the value with a FILE pointer. That also
works, but you can't write to that either for the same reason.

I am familiar with writing to files created by fopen where one
fprintf's to the named file pointer, but I must be confused as to what
to put in the fprintf(fd,""); statement.

Any ideas are greatly appreciated. Thank you.
--

Martin McCormick WB5AGZ Stillwater, OK
OSU Center for Computing and Information Services Network Operations Group
Nov 13 '05 #1
5 2564
ma****@okstate.edu (Martin McCormick) writes:
I am obviously confused about how to write to the file created
by the mkstemp function.


mkstemp is not a standard C function. Please discuss it in a
newsgroup devoted to whatever standard it is in (if there is
one). In comp.lang.c, we discuss only the standard C programming
language.
--
"It wouldn't be a new C standard if it didn't give a
new meaning to the word `static'."
--Peter Seebach on C99
Nov 13 '05 #2
Ben Pfaff wrote:
ma****@okstate.edu (Martin McCormick) writes:
I am obviously confused about how to write to the file created
by the mkstemp function.

mkstemp is not a standard C function. Please discuss it in a
newsgroup devoted to whatever standard it is in (if there is
one). In comp.lang.c, we discuss only the standard C programming
language.


man 3 mkstemp on my Debian system advises:

Don't use this function, use tmpfile(3) instead. It is better
defined and more portable.

--
Tom Zych
This is a fake email address to thwart spammers.
Real address: echo 'g******@cbobk.pbz' | rot13
Nov 13 '05 #3
Martin McCormick wrote:

I am obviously confused about how to write to the file created
by the mkstemp function.

Not a standard C function. I believe it is POSIX, so I advise posting to
comp.unix.programmer or a newsgroup specifically for your
implementation.


Brian Rodenborn
Nov 13 '05 #4
Martin McCormick wrote:

I am obviously confused about how to write to the file created
by the mkstemp function.

Not a standard C function. I believe it is POSIX, so I advise posting to
comp.unix.programmer or a newsgroup specifically for your
implementation.


Brian Rodenborn
Nov 13 '05 #5
Tom Zych <tz******@pobox.com> writes:
Ben Pfaff wrote:
ma****@okstate.edu (Martin McCormick) writes:

I am obviously confused about how to write to the file created
by the mkstemp function.

mkstemp is not a standard C function. Please discuss it in a
newsgroup devoted to whatever standard it is in (if there is
one). In comp.lang.c, we discuss only the standard C programming
language.


man 3 mkstemp on my Debian system advises:

Don't use this function, use tmpfile(3) instead. It is better
defined and more portable.


And even better, on-topic for this NG.

-Micah
Nov 13 '05 #6

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

Similar topics

2
by: marco | last post by:
Hello, I having a problem creating directories with Python 2.3.4 (compiled with gcc 3.2.2, under Linux 2.4.20-31.9). I'm writing a plugin which works in the following way: GUI --...
2
by: djw | last post by:
Hi, c.l.p'ers- I working on some code that creates a temporary file on Linux. I found some code that the BDFL posted previously on the newsgroup and adapted it for my use. I can't get the...
4
by: Bradley M. Small | last post by:
I have a web application that works fine under Window 2000 but breaks under Windows XP. If it is served form a Win2k box, it makes a list of files in the "reports" directory. If server on XP the...
3
by: Denny Huber | last post by:
Here's my dilemma: We are going to split our monolithic MFC app into a front-end GUI and an Engine. We will re-write the front-end GUI as a WinForms exe and call from there into the Engine. ...
9
by: billiejoex | last post by:
Hi there. I'm trying to generate a brand new file with a unique name by using tempfile.mkstemp(). In conjunction I used os.fdopen() to get a wrapper around file properties (write & read methods,...
50
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): ...
1
by: Ben Keshet | last post by:
Hi Pythoneers, I have a question about a code I wrote with the help of someone. The code below copy a few lines from different files into one file. It works fine as it is given here and...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
0
by: LoriFranklin | last post by:
I'm a bit of a newbie here. I've learned a lot from reading the posts you all have here. I need some help uploading files using an asp form. I am using some code that I found from Jacob at...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.