Answer to Question #306506 in UNIX/Linux Programming for panda

Question #306506

Write C program/ shell script which use few of the system calls directly.


1
Expert's answer
2022-03-08T07:11:18-0500

// C program to illustrate 

// open system call 

#include<stdio.h> 

#include<fcntl.h> 

#include<errno.h> 

extern int errno; 

int main() 

{     

    // if file does not have in directory 

    // then file foo.txt is created. 

    int fd = open("foo.txt", O_RDONLY | O_CREAT); 

      

    printf("fd = %d/n", fd); 

      

    if (fd ==-1) 

    { 

        // print which type of error have in a code 

        printf("Error Number % d\n", errno); 

          

        // print program detail "Success or failure" 

        perror("Program");                 

    } 

    return 0; 

}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS