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

will the program compile? int i; scanf(“%d”,i); printf(“%d”,i);

3 Answers  


what are far pointers?

1 Answers  


What are valid signatures for the Main function?

0 Answers  


What is a global variable in c?

0 Answers  


What are header files why are they important?

0 Answers  


How does #define work?

0 Answers  


code for quick sort?

0 Answers  


Are comments included during the compilation stage and placed in the EXE file as well?

0 Answers  


Explain following declaration int *P(void); and int (*p)(char *a);

3 Answers  


Tell me the use of bit field in c language?

0 Answers  


write a program to arrange the contents of a 1D array in ascending order

4 Answers  


Write a program to find given number is even or odd without using any control statement.

2 Answers  


Categories