Hello I am taking a class and I have to use system calls to make a program similiar to the cat utility in unix,,,I am using c++ on a linux server, I tried everything with no luck
I need to use the system calls open(); read(); and close();
I have a file called test.txt,, I have to use command line arguments to open a file for example my program is called mycat,,,I have to type on the command line
mycat test.txt when I hit enter in should open the file and display it on the screen... My code is below what am I doing wrong this code has errors and will not run
any advice will be helpful Thank you in advance
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(char *pathname, int oflag, int mode);
int read(int fd, char *buf, int size);
int close(int fd);
int main (int argc, char *argv[])
{
int fd;
int readd;
char buff[300];
fd = open(fd, O_RDONLY);
readd = read (fd, buff, 1);
close (fd);
return 0;
}