Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <string.h>
- int main()
- {
- int source_fd,char_read;
- char* path="/root/E2L/emp"; // file name
- char buf[128];
- memset(buf, 0 ,sizeof(buf));
- if ((source_fd = open(path, O_RDONLY)) < 0) {
- perror("Open source failed:");
- exit(2);
- }
- if((char_read = read(source_fd,buf,sizeof(buf)-1)) < 0){
- perror("Read error :");
- exit(2);
- }
- printf("Characters read = %d \n",char_read);
- printf("%s\n",buf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement