The fopen() command attempts to open the specified file. In this case it's test.txt in the same folder as the application. Remember, if the file includes a path then all the back spaces must be doubled up. "c:\folder\test.txt" is wrong, you must use "c:\\folder\\test.txt".
As the filemode is "wb", we are writing to a binary file. The file will be created if it doesn't exists and if it does then whatever was in it gets deleted. If the call to fopen fails, perhaps because the file was open, or the name contains invalid characters or an invalid path then fopen returns the value 0.
Although you could just check for ft being non zero (success), I added a FileSuccess() function to do this explicitly. On windows, it outputs the success/failure of the call (with the what it's doing- eg opening the file) and the filename. It's a little onerous if you are after performance so you might limit this to debug. Note that on Windows there is very little overhead outputting text to the system debugger.
fwrite(mytext,sizeof(char),strlen(mytext), ft) ;The fwrite() calls outputs the specified text. The 2nd and 3rd parameters are the size of the characters and the length of the string. Both are defined as being size_t which is unsigned integer. The result of this call is to write count items of the specified size. Note that with binary files, even though you are writing a string (char *) it does not append any carriage return or line feed characters. If you want those, you must explicitly include them in the string.
On the next page : File Modes

