hi guys, so iam writing a program which creates a .bat file in a directory and copies it to another directory through copyfile...the problem is that while the .bat file is created properly but when it's copied to the other directory an error occurs saying its not a win32 appropriate program and when i open it there is a blanc file...same thing happens when i try it with .txt files..so i wonder if copyfile is used only for .exe files...and if so how can i accomplish it with .bat

win32 api function CopyFile() can be used with any file type. Post your code so that we can see what you did wrong. When CopyFile() returns zero value, get the error number from GetLastError(). Then call FormatMessage() to get the error message text.

here it is..
#include <stdlib.h>
#include <windows.h>
int main()

FILE* p;





You opened the file for writing. I'm guessing it should be closed before you call CopyFile.

Adding code tags (click on the [code] icon at the top of your editing window), improves your code's readability, greatly.

omg such a stupid mistake thaks for ur time though :)