M
Martin McCormick
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.
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.