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

Write a program to add a given duration with time(24hrs format)

1 Answers   Protech,


What is the Purpose of 'extern' keyword in a function declaration?

0 Answers  


how memory store byte

4 Answers   Huawei,


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

0 Answers  


How can type-insensitive macros be created?

0 Answers  






What are the different types of constants?

0 Answers  


the output will be #include<stdio.h> int main () { int i; i = 9/2; printf("%i",i); return 0; }

4 Answers   CMC, TCS,


What is the purpose of clrscr () printf () and getch ()?

0 Answers  


How many ways are there to swap two numbers without using temporary variable? Give the each logic.

9 Answers  


What are local and global variables?

3 Answers  


What is extern c used for?

0 Answers  


#define MAX 3 main() { printf("MAX = %d \n",MAX ); #undef MAX #ifdef MAX printf("Vector Instituteā€); #endif

4 Answers   IBM, Vector,


Categories