[CP 2] M7 - File Handling

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 44

flashcard set

Earn XP

Description and Tags

45 Terms

1
Filename
Refers to the name of the file
New cards
2
fclose()
Closes a file
New cards
3
w
File mode that opens or create a text file in writing mode
New cards
4
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;

}
New cards
5
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);

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

}
New cards
19
<<
Which operator is used to insert the data into the file?
\>>
<<
New cards
20
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
New cards
21
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
New cards
22
fopen()
Writes a character to a file:
New cards
23
getc()
Reads a character from a file:
New cards
24
FILE *fp;
What is the correct syntax for declaring a file pointer?
New cards
25
fopen()
Creates a new file or open an existing file
New cards
26
a
File mode that opens a text file in append mode
New cards
27
text
By default, all the files in C++ are opened in \_________ mode.
New cards
28
ifstream
Which stream class is to only read from files?
New cards
29
Which header file is required to use file I/O operations?
New cards
30
reading a file
The ifstream would be used when:
New cards
31
fprint()
Writes a set of data to a file
New cards
32
fclose
It is the inverse of fopen, it breaks the connections between the file pointer and the external nam that was established by fopen
New cards
33
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;

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

fstream

ifstream

ofstream

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

\>>

<<

<
New cards
42
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;

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

iostream

ifstream

fstream

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

Explore top notes

note Note
studied byStudied by 310 people
359 days ago
5.0(3)
note Note
studied byStudied by 6 people
476 days ago
5.0(1)
note Note
studied byStudied by 11 people
83 days ago
5.0(1)
note Note
studied byStudied by 64 people
38 days ago
5.0(1)
note Note
studied byStudied by 89 people
993 days ago
5.0(1)
note Note
studied byStudied by 88 people
620 days ago
5.0(1)
note Note
studied byStudied by 16 people
376 days ago
5.0(1)
note Note
studied byStudied by 100 people
769 days ago
4.0(1)

Explore top flashcards

flashcards Flashcard (34)
studied byStudied by 5 people
298 days ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 4 people
656 days ago
4.5(2)
flashcards Flashcard (220)
studied byStudied by 2 people
103 days ago
5.0(1)
flashcards Flashcard (93)
studied byStudied by 8 people
39 days ago
5.0(1)
flashcards Flashcard (56)
studied byStudied by 6 people
754 days ago
5.0(1)
flashcards Flashcard (137)
studied byStudied by 14 people
170 days ago
5.0(1)
flashcards Flashcard (254)
studied byStudied by 51 people
168 days ago
5.0(1)
flashcards Flashcard (26)
studied byStudied by 15 people
747 days ago
5.0(1)
robot