C Programming - Input / Output - Discussion
Discussion Forum : Input / Output - General Questions (Q.No. 10)
10.
Consider the following program and what will be content of t?
#include<stdio.h>
int main()
{
FILE *fp;
int t;
fp = fopen("DUMMY.C", "w");
t = fileno(fp);
printf("%d\n", t);
return 0;
}
Answer: Option
Explanation:
fp = fopen("DUMMY.C", "w"); A file DUMMY.C is opened in write mode and returns the file pointer to fp
t = fileno(fp); returns the handle for the fp stream and it stored in the variable t
printf("%d\n", t); It prints the handle number.
Discussion:
10 comments Page 1 of 1.
Irresistible gal said:
1 decade ago
The word handle to mean a pointer that points to an "object" that represents a resource - often an OS resource, whereas a pointer just points to some memory. If you have a handle to something, you shouldn't try to read and write bytes into it directly, but manipulate it through provided methods.
Often handles are implemented as an opaque void *, which is further encouragement not to try to directly dereference it.
Often handles are implemented as an opaque void *, which is further encouragement not to try to directly dereference it.
Vijeta said:
1 decade ago
#include<stdio.h>
void main()
{
printf("\nvi");
printf("\bje");
printf("\rta");
}
What will be the output of ths program?
void main()
{
printf("\nvi");
printf("\bje");
printf("\rta");
}
What will be the output of ths program?
(1)
Gaurav Tanpure said:
1 decade ago
Need more explanation on handle. Please can anyone explain any particular example for handle or at least explain execution of above programme.
Deepak Raj said:
9 years ago
The handle is nothing but same as cookies in Java. It points to the index of a file stored.
Sundar said:
1 decade ago
@Vijeta
In Turboc (DOS):
----------------
tae
In Linux:
---------
vije
ta
In Turboc (DOS):
----------------
tae
In Linux:
---------
vije
ta
Saksham Gupta said:
1 decade ago
@Girl.
\b is backspace.
\r is carriage return
\b is backspace.
\r is carriage return
Nayna said:
1 decade ago
What is the associated handle means?
Rajeshwaran said:
7 years ago
Please explain fileno(fp) function.
(1)
GIRL said:
1 decade ago
What does \b do?
Atul sing bankoti said:
10 years ago
What is handle?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers