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 is the basis for selection of arrays or pointers as data structure in a program

0 Answers   TCS,


Magic square

0 Answers  


When should the const modifier be used?

0 Answers  


can u give me the good and very optimised code for a car racing game?

0 Answers  


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

0 Answers  






Compare and contrast compilers from interpreters.

0 Answers  


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

0 Answers   ADP,


What does a function declared as pascal do differently?

0 Answers  


Without Computer networks, Computers will be half the use. Comment.

0 Answers  


Which header file is essential for using strcmp function?

0 Answers  


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

0 Answers   Amazon,


#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a==0.5) printf("yes"); else printf("no"); getch(); }

9 Answers   TCS,


Categories