Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The correct C statement to close an input or output file is closef. True False I

ID: 3858647 • Letter: T

Question

The correct C statement to close an input or output file is closef. True False In C, fscanf() is used to: print data to the computer screen. read in data from a file. read input from the keyboard. write data to a file. To read data from an input file in C, you would use: scaff fscanff fscan fscanf What is the C statement required to send output to a data file? fprintf printff printf writef When a file nointer is declared, it is good practice to set its value to NULL in order to avoid undefined behavior. True False To open a file in C, it is necessary to know the file path and mode in which you want to open the file. True False

Explanation / Answer

Hi,Let me know if you need more information:-

=============================================

45. We use fclose() function to close. NOT [ closef ]
main() {
   FILE *fp;
   fp = fopen("tmp.txt", "w+");
   fclose(fp);
}

============================

46. fscanf used to read input from a stream

Syntax:- int fscanf(FILE *stream, const char *format, ...)

Example:

int main()
{
   char str1[10];
   FILE * fp;

   fp = fopen ("file.txt", "w+");//File content: chegg

   fscanf(fp, "%s", str1);//reads from file stream to str1 as string

   printf("Read String |%s| ", str1 );

   fclose(fp);
}

=================================================

47.fscanf used to read input from a stream

Syntax:- int fscanf(FILE *stream, const char *format, ...)

Example:

int main()
{
   char str1[10];
   FILE * fp;

   fp = fopen ("tmp.txt", "w+");//File content: chegg

   fscanf(fp, "%s", str1);//reads from file stream to str1 as string

   printf("Read String |%s| ", str1 );

   fclose(fp);
}

==============================================

48.We use fprintf .

printff - not exist;printf --> stdout;writef not exst but fwrite exist.

Syntax:- int fprintf(FILE *stream, const char *format, ...)

Example:

int main()
{
   FILE * fp;

   fp = fopen ("tmp.txt", "w+");
   fprintf(fp, "%s %s %s %d", "We", "are", "in", 2017);

   fclose(fp);

   return(0);
}

===============================================

49.TRUE

because it may cause some issues while exexcution of program.if it is not pointed to NULL.

=================================

50:TRUE

Syntax of fopen will be like below:-

=========================

FILE * fopen ( const char * filename, const char * mode ); ///so you must mention the mode and file name.

=================================================

Thanks

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote