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;
}
size of "DUMMY.C" file
The handle associated with "DUMMY.C" file
Garbage value
Error in fileno()
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.

Rajeshwaran said:   7 years ago
Please explain fileno(fp) function.
(1)

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.

Atul sing bankoti said:   10 years ago
What is handle?

Saksham Gupta said:   1 decade ago
@Girl.

\b is backspace.
\r is carriage return

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.

GIRL said:   1 decade ago
What does \b do?

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.

Sundar said:   1 decade ago
@Vijeta

In Turboc (DOS):
----------------
tae

In Linux:
---------
vije
ta

Vijeta said:   1 decade ago
#include<stdio.h>

void main()
{
printf("\nvi");
printf("\bje");
printf("\rta");

}

What will be the output of ths program?
(1)

Nayna said:   1 decade ago
What is the associated handle means?

Post your comments here:

Your comments will be displayed after verification.