What will be the output of the following C code if following commands are used to run (considering myfile exists)?
gcc -otest test.c
./test < myfile
#include <stdio.h>
int main()
{
char c = 'd';
putchar(c);
}
gcc -otest test.c
./test < myfile
#include <stdio.h>
int main()
{
char c = 'd';
putchar(c);
}A. Compile time error (after first command)
B. d in the myfile file
C. d on the screen
D. Undefined behaviour
Answer: Option C
Related Questions on File Input Output
In C, which library is used for file operations such as reading and writing files?
A. stdio.h
B. iostream.h
C. fileio.h
D. files.h
Which function is used to open a file in C for writing?
A. fopen()
B. open()
C. writefile()
D. createfile()
What does 'FILE' represent in C when working with files?
A. A built-in data type for files
B. A file descriptor
C. A file pointer
D. A file structure
How do you check if a file was opened successfully in C?
A. Use the 'filestatus' variable
B. Check the return value of fopen()
C. Use the 'fileopen' function
D. Check the file's size

Join The Discussion