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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a protocol in c?

559


Differentiate Source Codes from Object Codes

822


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

672


What does sizeof int return?

594


What happens if you free a pointer twice?

610






Why do we use int main instead of void main in c?

621


Explain what is the benefit of using enum to declare a constant?

588


When should structures be passed by values or by references?

585


Why c is called object oriented language?

586


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

654


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

608


how many key words availabel in c a) 28 b) 31 c) 32

635


Why is c fast?

604


Why void is used in c?

566


What are the 4 types of functions?

573