How to write to file? VC++

So I try this:

FILE *filepointer;
errno_t err;

err = fopen_s(&filepointer, "C:\Documents and Settings\user\MyDocuments\OutputTest.txt", "w");

fprintf( filepointer, "%#.10e", Object->Values[0]);

and I get:

Debug Assertion Failed!
Expression:(str !=NULL)

What is going on? How do I write to a file in VC++ 2008?
As a quick guess your path needs to have double \ otherwise each \ will become an escape code using the next character, and that will generate a file path that dosn't exist.

try
err = fopen_s(&filepointer, "C:\\Documents and Settings\\user\\MyDocuments\\OutputTest.txt", "w");

you could confirm the file is opened by checking the variable err you defined.
Last edited on
That doesn't open the file... =(
does the path exist and does your application have write privaliges to that folder?
Just try writing a file to "C:\\Output.txt" to findout.
Last edited on
Topic archived. No new replies allowed.