fwrite error???
-
Why would this: fwrite(dataPtr,sizeof(unsigned char),(sizeof(unsigned char)*datalength),filePtr); ALWAYS return 0 byte written :confused: I can open the file ok using filePtr = fopen (DataFile,"wb"); but whenever I try to write the data down it fails. Anyideas? Thanks!
-
Why would this: fwrite(dataPtr,sizeof(unsigned char),(sizeof(unsigned char)*datalength),filePtr); ALWAYS return 0 byte written :confused: I can open the file ok using filePtr = fopen (DataFile,"wb"); but whenever I try to write the data down it fails. Anyideas? Thanks!
-
lol I just checked that and it seems my data pointer is not pointing to the right place. LOL. fix that and then try again. Thanks. I might be back. :-\
-
ok pointers are all correct now, data is where I need it to be. But still, no data being written when calling the fwrite. :~
Did the file open succeed? If you look at the data buffer in the debugger is it what you expect? What does errno tell you? Why aren't you checking what fopen() and fwrite() return. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
-
Why would this: fwrite(dataPtr,sizeof(unsigned char),(sizeof(unsigned char)*datalength),filePtr); ALWAYS return 0 byte written :confused: I can open the file ok using filePtr = fopen (DataFile,"wb"); but whenever I try to write the data down it fails. Anyideas? Thanks!
Firstly, your code should be like this: fwrite(dataPtr, sizeof(unsigned char), datalength, filePtr); It does not make any difference in case of a char, but if you use integers for example, your code will try to write 4x4xdatalength = 16xdatalength bytes of data, instead of writing 4xdatalength bytes. Anyway, apart from that be sure to check the datalength. Check out whether it is 0 or not. If it still does not work, add the following line after writing to the file: fflush (filePtr); Mustafa Demirhan http://www.macroangel.com Sonork ID 100.9935:zoltrix
They say I'm lazy but it takes all my time
-
Firstly, your code should be like this: fwrite(dataPtr, sizeof(unsigned char), datalength, filePtr); It does not make any difference in case of a char, but if you use integers for example, your code will try to write 4x4xdatalength = 16xdatalength bytes of data, instead of writing 4xdatalength bytes. Anyway, apart from that be sure to check the datalength. Check out whether it is 0 or not. If it still does not work, add the following line after writing to the file: fflush (filePtr); Mustafa Demirhan http://www.macroangel.com Sonork ID 100.9935:zoltrix
They say I'm lazy but it takes all my time