Short answer Name Exam 2 For 712 give a brief description o
Solution
#include <stdio.h>
void run1()
{
int a; //Declares a variable a.
FILE *file = fopen(\"input.txt\", \"r\"); //Defines a file pointer file in read mode.
fscanf(\"input.txt\", \"%d\", &a); //This leads to error, as fscanf() 1st parameter should be a file pointer and not a character array.
}
void run2()
{
int a; //Declares a variable a.
FILE *file = fopen(\"input.txt\", \"w\"); //Defines a file pointer file in write mode.
fscanf(file, \"%d\", &a); //This leads to error, as fscanf() will read a file but it is opened in write mode.
}
void run3()
{
int a; //Declares a variable a.
FILE *file = fopen(\"input.txt\", \"a\"); //Defines a file pointer file in append mode.
fprintf(file, \"%d\", &a); //This appends the address of the variable a to the file input.txt.
}
void run4()
{
int a; //Declares a variable a.
FILE *file = fopen(\"input.txt\", \"r\"); //Defines a file pointer file in read mode.
fscanf(file, \"%d\", &a); //This reads an integer from the file pointer file into a variable a.
}
