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

# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }

5 Answers  


Is there any possibility to create customized header file with c programming language?

0 Answers  


Why we use int main and void main?

0 Answers  


while running a program, i got the msg that press return key to exit.what that mean in C as there are no such options as far i know.

1 Answers   TCS,


How do I convert a string to all upper or lower case?

0 Answers  






What are register variables? What are the advantage of using register variables?

0 Answers   TISL,


application attempts to perform an operation?

0 Answers  


What are pointers in C? Give an example where to illustrate their significance.

0 Answers   Wipro,


how to do in place reversal of a linked list(singly or doubly)?

3 Answers  


why i join syntel?

23 Answers   ABC, Syntel, TCS,


How to write a multi-statement macro?

0 Answers  


What is the translation phases used in c language?

0 Answers  


Categories