Next Previous Contents

## 3.207 unlink

> Function

>   Delete a file.

> Header

>   `unistd.h`

> Declaration

>   `int __fastcall__ unlink (const char* name);`

> Description

>   `unlink` deletes the file with the given name. On success, zero is returned. On error, -1 is returned and `errno` is set to an error code describing the reason for the failure.

> Limits

>   - The use of this function is discouraged. Please use `remove` instead, which is a native ANSI C function and does the same.
>   - This function is not available on all cc65 targets (depends on the availability of file I/O).
>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - Instead of `unlink`, `remove` should be used, which has the same semantics, but is more portable, because it conforms to the ISO C standard.
> Availability

>   POSIX 1003.1

> See also

>   remove

> Example

>       #include <stdio.h>
>       #include <unistd.h>

>       #define FILENAME "helloworld"

>       if (unlink (FILENAME) == 0) {
>           printf ("We deleted %s successfully\n", FILENAME);
>       } else {
>           printf ("There was a problem deleting %s\n", FILENAME);
>       }

Next Previous Contents