[CP 2] M7 - File Handling

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/44

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

45 Terms

1
New cards
Filename
Refers to the name of the file
2
New cards
fclose()
Closes a file
3
New cards
w
File mode that opens or create a text file in writing mode
4
New cards
65
What is the output of the given program?

\#include < iostream \>

using namespace std;

int main ()

{

char str[] \= "Steve jobs";

int val \= 65;

char ch \= 'A';

cout << val << endl;

return 0;

}
5
New cards
Gets a character, put it into a file pointer until an enter is pressed
What does the following code do?

while( (ch \= getchar()) !\= '\n') {

putc(ch, fp);

}
6
New cards
fprintf()
A function directly writes into the file:
7
New cards
Append
An operation wherein data is added to the existing data of a file
8
New cards
fp \= fopen("one.txt", "w");
What is correct syntax for fopen()?
9
New cards
File pointer
It points to a structure that contains about the file:
10
New cards
fstream
A C++ library that allows working with files
11
New cards
fstream
Which of the following is used to create a stream that performs both input and output operations?
12
New cards
fstream
Which stream class is used to both read and write on files?
13
New cards
After pressing return key
When will the cin can start processing of input?
14
New cards
writes to a file
What is meant by ofstream in c++?
15
New cards
fstream
Which stream class is used to both read and write on files?
16
New cards
bool
What is the return type open() method?
17
New cards
getline
What can be used to input a string with blank space?
18
New cards
65
What is the output of the given program?

\#include < iostream \>

using namespace std;

int main ()

{

char str[] \= "Steve jobs";

int val \= 65;

char ch \= 'A';

cout << val << endl;

return 0;

}
19
New cards
<<
Which operator is used to insert the data into the file?
\>>
<<
20
New cards
Gets a character, put it into a file pointer until an enter is pressed
What does the following code do?

while( (ch \= getchar()) !\= '\n') {

putc(ch, fp);

}


Gets a character, put it into a file pointer until an enter is pressed

Gets a character

Puts character into a variable

Gets a character until enter key is pressed
21
New cards
fgetc()
this function reads the character from the current pointer's positiona nd upon successful read moves the pointer to the next character in the file
22
New cards
fopen()
Writes a character to a file:
23
New cards
getc()
Reads a character from a file:
24
New cards
FILE *fp;
What is the correct syntax for declaring a file pointer?
25
New cards
fopen()
Creates a new file or open an existing file
26
New cards
a
File mode that opens a text file in append mode
27
New cards
text
By default, all the files in C++ are opened in \_________ mode.
28
New cards
ifstream
Which stream class is to only read from files?
29
New cards
Which header file is required to use file I/O operations?
30
New cards
reading a file
The ifstream would be used when:
31
New cards
fprint()
Writes a set of data to a file
32
New cards
fclose
It is the inverse of fopen, it breaks the connections between the file pointer and the external nam that was established by fopen
33
New cards
error
What is the output of the given program?

\#include < iostream \>

using namespace std;

int main ()

{

char str[] \= "Steve jobs";

int val \= 65;

char ch \= 'A';

cout << val << endl;

return 0;

}
34
New cards
is_open
Which member function is used to determine whether the stream object is currently associated with a file?
35
New cards
\#include
Which header file is used for reading and writing to a file?
36
New cards
fclose(fp);
What is the correct syntax for fclose()?
37
New cards
File
It is created for the permanent storage of data.
38
New cards
end of file
EOF means \______________________________
39
New cards
r
File mode that opens a text in reading mode
40
New cards
fstream
Which of the following header file is required for creating and reading files?

fstream

ifstream

ofstream

stream
41
New cards
<<
Which operator is used to insert the data into the file?
\>

\>>

<<

<
42
New cards
error
What is the output of the given program?

\#include < iostream \>

using namespace std;

int main ()

{

char str[] \= "Steve jobs

int val \= 65;

char ch \= 'A';

cout << val << endl;

return 0;

}
43
New cards
ofstream
Which of the following is used to create an output stream?

iostream

ifstream

fstream

ofstream
44
New cards
ofstream
Which stream class is to only write on files?
45
New cards
file ata
sequence of bytes on the disk where a group of related data is stored