Unix to Windows Porting Dictionary for HPC

RSS

Links

Function List

unlink


Unix

header file: unistd.h

int unlink(const char *filename);

Windows

header file: stdio.h

int _unlink(const char *filename);

Purpose

This function deletes the specified file.

Discussion

The Windows and Unix versions of this function differ only in name and the needed header file; changing the name should be all that is required to port between the two operating systems. Windows also provides a similar function, _wunlink, that has wide-character support.

Example of Use in Windows

#include <stdio.h>

int main( void )
{
   if(_unlink("crt_unlink.txt"))
      printf("Deleted 'CRT_UNLINK.TXT'\n");
   else
      perror("Could not delete 'CRT_UNLINK.TXT'");
}

  
blog comments powered by Disqus
Valid HTML 4.01 Transitional Valid CSS!