Advertisement

deleting a file

Started by November 18, 2000 12:32 AM
12 comments, last by slightlywhacked 24 years, 1 month ago
Actually, now that I have checked the standard, remove is indeed a standard function. My apologies.
This is what i tried

#include
#include
#include


main()
{
if(remove("filename.suffix") == -1)
printf("Couldn''t delete file");
else
printf("deleted");


return(0);
}

i get a linking error

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16


and

Debug/temp deleter.exe : fatal error LNK1120: 1 unresolved externals

BAHcows go moomoos go cow
Advertisement
the includes in the above post were not posted?? anyways i included the following
fstream.h
iostream.h
stdio.h
BAHcows go moomoos go cow
slightlywhacked, you tried to compile this as a w32 graphical app. You'll have to compile as a console app, because the entrypoint for a conapp is 'main' as opposed to 'WinMain' for a gui application. Nevertheless, 'remove' will work in both (you'll only have to include stdio.h for it).

As for changing your directory, use chdir.

if(chdir("c:\\windows\temp") == -1)  printf("Couldn't change directory");else  printf("directory changed!"); 




Edited by - entrox on November 19, 2000 6:18:21 AM
.entrox

This topic is closed to new replies.

Advertisement