ESC151 For give a brief description of what eachof factions

ESC151 For give a brief description of what eachof factions would do tmost likely crash is something some of functions might do) these 7)(2 points) void run 10 FILE file fopen input Dr\" r\"); fscanf( input txt\", nod\', &a;): 8)(4 points) void run 20 FILE file fopen input w fscanf(file, \"%d\", &a;) 9) (4 points) void run30 FILE file fopen input. a fprintfofile, \"%d\'.&a;); 100 (4 points) void run 40 int a; FILE \"file fopen( input.txt\",\"r\"); fscanf(file, \"%d\", &a;);

Solution

Here is the code explained for you:

#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.
}

 ESC151 For give a brief description of what eachof factions would do tmost likely crash is something some of functions might do) these 7)(2 points) void run 10

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site