how to get the starting address of file stored in harddisk
through 'C'program.

Answers were Sorted based on User's Feedback



how to get the starting address of file stored in harddisk through 'C'program...

Answer / amvel

U can use FILE pointer, to find the address of a file in ur
hard disk.

What u hav to do is, Just pass the directory of the file to
lib function fopen(), to which u wanted to know the
address, and assign the return value of the function to a
FILE pointer. Now the file pointer holds the address of the
file.

Lets, look at the below code for better clarity.

#include<stdio.h>
#include<conio.h>

void main()
{
FILE *fp ;
char ch ;
fp = fopen("C:\\Documents and
Settings\\Vadivelt\\file.txt", "w+");

/*Gives the starting adds of ur file in the hard disk*/
printf("%d \n", fp);

_getch();
}

Is This Answer Correct ?    4 Yes 2 No

how to get the starting address of file stored in harddisk through 'C'program...

Answer / venu

FILE *fp ; is a virtual address in library.
You need meta data to find the location on hard disk.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Interview Questions

What are macros in C?

2 Answers  


Write a C program to perform some of the operation which can be performed using Single linked list

1 Answers   Qualcomm,


write a program in c language for the multiplication of two matrices using pointers?

8 Answers   Ignou,


What is a header file?

0 Answers  


What are variables and it what way is it different from constants?

0 Answers  


I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?

3 Answers  


How many types of operator or there in c?

0 Answers  


a linear linked list such that the link field of its last node points to the first node instead of containing NULL a) linked list b) circular linked list c) sequential linked list d) none

0 Answers  


What are the characteristics of arrays in c?

0 Answers  


What is the maximum no. of arguments that can be given in a command line in C.?

0 Answers   HCL,


sqrt(x+sqrt(x+sqrt(x+sqrt(x))))=2; Find the value of x?

4 Answers   Subex,


Why data types in all programming languages have some range? Why ritche have disigned first time likethat?Why not a single data type can support all other types?

2 Answers   Excel,


Categories