Q01 The FILE structure contains information that allows a p
Q-01 *
The FILE structure contains information that allows a program to refer to a file for read and write operations using a pointer. Which line creates a File structure pointer?
30
21
10
12
Q-02 *
Which line creates the actual File structure object in memory (hint - successful open operation)
12
10
22
39
Q-03 *
The \'fopen\' function opens or creates a file in the default folder (line 12) - what is the default folder in CodeBlocks?
The Release folder
The object folder
The source code folder
The include folder
Q-04 *
The \'fopen\' function parameter \"w+\" creates a file even if one already exists?
True
False
Q-05 *
Which \'fopen\' function parameter would specify to append to the existing file?
\"r+\"
\"w\"
\"w+\"
\"a\"
Q-06 *
If \"C:\\MyDocuments\\Temp\\file.txt\" is used as the first parameter in \'fopen\' function, which folder is the parent folder?
file.txt
Temp
MyDocuments
C:\\
Q-07 *
Is Line 14 Text or Binary file output?
Text
Binary
Q-08 *
Is Line 15 Text or Binary file output?
Text
Binary
Q-09 *
How could Text and/or Binary file I/O be used within the same file? Because all I/O for a file is strictly based on what unit?
integer
block
byte
binary
Q-10 *
Lines 21-27 print item (1.), single characters from \"file.txt\" with what outcome?
first string
second string
whole file
255 chars
Q-11 *
What stops the read operation in Lines 21-27
End-of-String
End-of-File
c==0
fp=NULL
Q-12 *
Lines 31-32 print item (2.). What stops the read operation?
End-of-String
End-of-File
Fgets second parameter
47 chars
Q-13 *
Line 34 \'fseek\' is relative to what part of the file?
Beginning
Current
End
Unspecified
Q-14 *
Line 34 has the same effect as which other line?
10 FILE pointer
12 fopen
23 feof
29 rewind
Q-15 *
Lines 36-37 print item (3.) - What stops the read operation?
End-of-String
End-of-File
Fgets second parameter - 10
47 chars
Q-16 *
Lines 36-37 - How many chars appear in the output (Item 3. - stdout)
47
9
255
8
Q-17 *
Line 41 is Text or Binary file input?
Text
Binary
Q-18 *
Line 41 how many characters is \'fread\' trying to input?
255
47
EoS
EoF
Q-19 *
Lines 40-42 (item 4.) - What stops the read operation?
End-of-String
End-of-File
fgets second parameter
47 chars
Q-20 *
Lines 40-42 print item (4.) How is the value of \'Length\' determined?.....fread returns the number of ??? items input
fp
255
block
sizeof(char)
10 11 12 13 14 15 16 17 18 19 26 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 #includeSolution
Dear following are the answers..
Ans-1: Line 10 creates a File structure pointer.
Ans-2: Line 12 creates the actual File structure object in memory.
Ans-3: Yes fopen\' function opens or creates a file in the default folder. - the default folder in CodeBlocks? is source code folder, the folder in which the source files are present.
Ans-4: True.--- mode Opens a file for both reading and writing operation. It first truncates the file to zero length if it exists, otherwise creates a file if it does not exist.
Ans-5: \'a\' mode---Opens a text file for writing in appending mode. If file does not exist, then a new file is created. If file exist, It start appending content.
Ans-6: In the given directory \"C:\\MyDocuments\\Temp\\file.txt\" MyDocument is the parent folder.
Ans:-7 Line 14 gives us Text output in standard Output Screen.fprintf sends formatted output to a stream i.e 0,1,2(0=standard input, 1= standard output, 2= standard error).
Ans:-8 Line 15 is a Binary output.The function fwrite() writes nmemb elements of data, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr. In the program fwrite printing This is my second string.To write into a binary file, you need to use the function fwrite(). The functions takes four arguments: Address of data to be written in disk, Size of data to be written in disk, number of such type of data and pointer to the file where you want to write.
Ans:-9 I/O of a file is strictly based on Block unit.In block I/O, data is transferred in blocks directly from the file to storage locations in memory with no conversion.
Ans-10: Lines 21-27 print item (1.), single characters from \"file.txt\" with reading whole file.It read file character by character untill the End of File is not reached.
Ans-11: End-of-File stops the read operation.
Ans-12 Lines 31-32 print item (2.). End-of-String stops the read operation.
Ans:13 Line 34 \'fseek\' is relative to begining part of the file. It sets the position to the begining of the file.
Ans:14: Line 34 has the same effect as rewind().The rewind function also sets the file position indicator for the stream pointed to by stream to the beginning of the file.
Ans:15: Line 36-37 print item (3.) - fgets second parameter that is why the read operation is stoped.
Ans:16:Lines 36-37 - 47 chars appear in the output (Item 3. - stdout).
Ans:17: Line 41 is Text input.It is reading the input stored in the buffer.
Ans:18: fread reads the character untill the EOS is not reached.
Ans-19: Lines 40-42 (item 4.) - read operation stops becuase the End-of-String is reached.
Ans-20: Lines 40-42 print item (4.) the value of \'Length\' determined by sizeof() operator......fread returns the number of char items input. fread return the number of bytes actually read from the stream opened by fopen function.
Kindly check and verify Thanks...!!!





