I'm trying to learn system calls for open,write and close a file. I use this sample and the result is:
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
Here's my program:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int main (int argc, char *argv[])
{
int fd1;
char buf[128];
fd1 = open("Desktop/this.txt", O_WRONLY);
if (fd1 == -1) {
perror("File cannot be opened");
return EXIT_FAILURE;
}
/* Enter the data to be written into the file */
scanf("%127s", buf);
write(fd1, buf, strlen(buf)); /* fd1 is the file descriptor, buf is the character array used to
hold the data, strlen(buf) informs the function that the number of bytes equal to the length of the
string in the buffer need to be copied */
close(fdl);
return 0;
}
locate cc1plus
? The issue is with installation of the compiler. – Karlson Apr 29 at 15:45