`#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
int main() {
int f_d = 0;
struct stat st;
f_d = open("test.txt",O_RDONLY);
// If lines 17 -21 and 25 to 30 are removed rrtest does not give error
if(-1 == f_d)
{
printf("\n NULL File descriptor\n");
return -1;
}
// If lines 17 -21 and 25 to 30 are removed rrtest does not give error
if(fstat(f_d, &st))
{
printf("\nfstat error: [%s]\n",strerror(errno));
close(f_d);
return -1;
}
rename("snazzyjazz.txt", "test2.txt");
int x = 0 ;
x = 5 ;
rename("test2.txt", "test3.txt");
int y = 0 ;
y = 5 ;
rename("test3.txt", "test4.txt");
return 0;
}
`#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
int main() {
int f_d = 0;
struct stat st;
// If lines 17 -21 and 25 to 30 are removed rrtest does not give error
if(-1 == f_d)
{
printf("\n NULL File descriptor\n");
return -1;
}
// If lines 17 -21 and 25 to 30 are removed rrtest does not give error
if(fstat(f_d, &st))
{
printf("\nfstat error: [%s]\n",strerror(errno));
close(f_d);
return -1;
}
rename("snazzyjazz.txt", "test2.txt");
int x = 0 ;
x = 5 ;
rename("test2.txt", "test3.txt");
int y = 0 ;
y = 5 ;
rename("test3.txt", "test4.txt");
return 0;
}