mkstemp question!!!

This is a discussion on mkstemp question!!! within the C Programming forums, part of the General Programming Boards category; i have a question on using mkstemp (creating a temporary file). as currently written, my code creates the temporary file ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    2

    Question mkstemp question!!!

    i have a question on using mkstemp (creating a temporary file).
    as currently written, my code creates the temporary file correctly but it doesn't want to write the testinput in it. any ideas why?

    Code:
    	char *filename = "tempXXXXXX";
    	char *testinput = "testing input data...";
    	FILE *tempfile;
    	int fd;
    
    	fd = mkstemp(strdup(filename));
    	tempfile = fdopen(fd, "w+");
    	fprintf(tempfile, testinput);
    much appreciation to whoever could help me!

    --zynnel
    Last edited by zynnel; 03-26-2003 at 04:36 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Perhaps you should actually read how the function works. If you did, you'd see something like:
    Since it will be modified, template must not be a string constant, but should be declared as a character array.
    You could of course actually pay attention to the return valud also...

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    2
    of course :-)
    that helped. thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21