Question: How do I run the program using a utility that traces system-calls for the following code using the dtrace command; #include #include int main() {
How do I run the program using a utility that traces system-calls for the following code using the dtrace command;
#include
int main() { char ch, source_file[100], des_file[100]; FILE *fptr1, *fptr2;
//Input file printf("Enter name of file to copy: "); scanf("%s", source_file); //Output file printf("Enter name of destination file: "); scanf("%s", des_file);
//Opens read mode fptr1 = fopen(source_file, "r"); //If copy file does not exist, program exits if(fptr1 == NULL) { printf(" '%s' does not exist Exiting... ", source_file); exit(0); }
//If destination file exists, program exits if(fptr2 = fopen(des_file, "r")){ printf(" '%s' already exist Exiting... ", des_file); exit(0); } //Opens write mode fptr2 = fopen(des_file, "w");
//Copies file contents character by character printf(" Copying contents... "); while (ch != EOF) { fputc(ch, fptr2); ch = fgetc(fptr1); } printf("File copied succesfully. ");
//Closes files to release resources fclose(fptr1); fclose(fptr2);
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
