I am running a simple program to open a file. Some details about the OS and processor:
.Ubuntu 64bits
.Processor AMD Ryzen 7
Everytime when i try to execute always receive this error: No such file or directory
Already installed sudo apt-get install lib32z1 but the problem remains.Here is the code of the C program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
>
void main(void)
{
char* filename = "~/Documents/Manipulation/addresses.txt";
printf("\nUsing fopen fuction");
FILE* arch = fopen(filename, "r");
if(arch == 0)
{
perror("fopen");
printf("\n arch is null");
exit(0);
}
else
{
printf("\n Arch is opened..");
}
}
One important detail is when I use the function open("addresses", O_RDONLY)
it works well.See the code below:
int fd;
printf("\nUsing open fuction");
fd = open ("addresses", O_RDONLY);
if(fd == 0)
{
fprintf(stderr, "can't open %s: %s\n", filename, strerror(errno));
exit(1);
}
else
{
printf("\n Arch is opened..");
}
Does someone know how to fix this?