Search Header Logo

C++ FILE HANDLING

Authored by Hannah G

Computers

University

Used 32+ times

C++ FILE HANDLING
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

char buffer[100];

FILE *p1, *p2;

p1 = fopen("myfile.txt", "w");

p2 = fopen("myfile2.txt", "a");

fputs("Buffered stream", p1);

fflush(p1);

setbuf(p2, NULL);

fputs("Unbuffered stream", p2);

fclose(p1);

fclose(p2);

What is the output in myfile.txt?

Error

Buffered stream

Unbuffered stream

Buffered and unbuffered stream

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

char buffer[100];

FILE *p1, *p2;

p1 = fopen("myfile.txt", "w");

p2 = fopen("myfile2.txt", "a");

fputs("Buffered stream", p1);

fflush(p1);

setbuf(p2, NULL);

fputs("Unbuffered stream", p2);

fclose(p1);

fclose(p2);

What is the output in myfile2.txt?

Error

Buffered stream

Unbuffered stream

Buffered and unbuffered stream

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

It writes a string (which need not contain a newline) to a file. It returns EOF if an error occurs, and a non-negative error otherwise.

fputc

fgetc

fputs

fopen

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

It writes the character c to the file and returns the character written or EOF if an error occurs.

fopen

fputc

fgetc

fgets

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

It points to a structure that contains things about the file

file pointer

file handling

node pointer

file structure

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When fopen() is not able to open a file, it returns ________

EOF

NULL

runtime error

compiler dependent

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is true about FILE *fp; ?

FILE is a stream

FILE is a keyword in C for representing files and fp is a variable of FILE type

FILE is a structure and fp is a pointer to the structure of FILE type

FILE is a buffered stream

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?