click below
click below
Normal Size Small Size show me how
Programming 2 File H
| Question | Answer |
|---|---|
| Writes a character to a file: | getc()??? |
| 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 |
| What is the correct syntax for declaring a file pointer? | FILE *fp; |
| Writes a set of data to a file | fprintf() |
| An operation wherein data is added to the existing data of a file | Append |
| Which stream class is used to both read and write on files? | fstream |
| What is correct syntax for fopen()? | fp = fopen("one.txt", "w"); |
| What is the correct syntax for fclose()? | fclose(fp); |
| Refers to the name of the file | Filename |
| It represents a sequence of bytes on the disk where a group of related data is stored. | File |
| The ifstream would be used when: | reading a file |
| Which member function is used to determine whether the stream object is currently associated with a file? | is_open |
| What can be used to input a string with blank space? | getline |
| Which header file is used for reading and writing to a file? | #include<fstream> |
| Which stream class is to only write on files? | ofstream |
| Which of the following header file is required for creating and reading files? | fstream |
| By default, all the files in C++ are opened in _________ mode. | Text |
| Which stream class is to only read from files? | ifstream |
| It represents a sequence of bytes on the disk where a group of related data is stored. | File |
| Mistakes | 1 |
| A function directly writes into the file: | fprintf() |
| Creates a new file or open an existing file | fopen() |
| Reads a character from a file: | getc()??? |
| File mode that opens a text file in append mode | a |
| Which of the following is used to create an output stream? | ofstream |
| Which header file is required to use file I/O operations? | <fstream> |
| A C++ library that allows working with files | fstream |
| Which of the following is used to create a stream that performs both input and output operations? | fstream |
| 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; } | Error |
| Mistakes | 1 |