CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Interview Success Kit - Get Success in Job Interviews Interview Success Kit - 30,000 Interview Que. & Ans.
Covers 30,000+ Interview Questions asked in actual MNC Interviews - all with model answers.
Get Your Dream Job Now - www.vyoms.com
Sponsored Links
Interview Questions
Our Services

INTERVIEW QUESTIONS C POINTERS IN C DETAILS
Question :
What is file pointer and its working method?

Posted by: mohan on 11/27/2012

Contact mohan Contact mohan
Category Pointers in C Interview Questions
Rating (3.1) By 39 users
Added on 11/27/2012
Views 2327
Rate it!
Answers:

when a pointer is pointing to the address of a file than it is called as a file pointer.
for example:
FILE *fp;
here in above statement we are declaring a file pointer.
there are many modes of opening a file.they are read ,write,append ..
they are as follows..
fp=fopen("filename.c",'r');
above statement is opening a file in read mode..



Posted by: kishore reddy

Contact kishore reddy Contact kishore reddy

C communicates with files using a new data type called a file pointer. This type is defined within stdio.h, and written as FILE *. A file pointer called output_file is declared in a statement like


FILE *output_file;



Posted by: Milind Kotibhaskar

Contact Milind Kotibhaskar Contact Milind Kotibhaskar

Basically a file pointer is capable to store address of a file which is created by fopen function.Using this pointer we can do operations(read,write,modify) on the file.



Posted by: SYED AMIDUL ISLAM

Contact SYED AMIDUL ISLAM Contact SYED AMIDUL ISLAM

File pointer is the pointer which holds the address of the file which is opened either in read or write or append or binary modes(r,w,a,r+,w+,a+,b).

FILE *fp;

This is the declaration of the file pointer.

Opening of the file is done by any one of the following.

fp = fopen("filename.txt","r"); or
fp = fopen("filename.TXT","w"); or
fp = fopen("filename.DAT","a"); or
fp = fopen("filename","r+"); or
fp = fopen("filename.txt","w+"); or
fp = fopen("filename.txt","a+"); or
fp = fopen("filename.txt","b");

When fopen opens the file successfully, fp holds the address of the first character in the file.

We can read or write into the file using the functions like fread() or fwrite().

After all operations, we have to close the file using fclose(fp);



Posted by: Syed Baseer Ahmed

Contact Syed Baseer Ahmed Contact Syed Baseer Ahmed

File pointer is a pointer which is used in file handling through file pointer we can open the file in write mode and read mode and also closed the file through file pointer.



Posted by: mohit kumar

Contact mohit kumar Contact mohit kumar

A special data type for handling files is defined in the stdio.h header file.

It is called the file pointer and has the syntax FILE*.

File pointers are used to open,read,write and close files.


FILE *file_ptr;
file_ptr=fopen("data.txt","w");

It is advisable to test the file pointer against NULL value if we get back NULL the actual operation /with the file/ has failed.

#include <stdio.h>

int main()
{

FILE *file_ptr;
file_ptr=fopen("data.txt","w");

if (file_ptr!=NULL)
{
printf("file created
");
fclose (file_ptr);
return 0;
}
else
{ printf("unable to create file
");
return 1;

}
}



Posted by: Andrew Gecse

Contact Andrew Gecse Contact Andrew Gecse

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification Enter the above shown code: *
    Inform me about updated answers to this question

    Related Questions
    View Answer
    How I can add two numbers in c language without using Arithmetic operators?
    View Answer
    What is pointer?
    View Answer
    What are the disadvantages of using Pointers.
    View Answer
    How to operate pointers in any pragram & how to develop our logic while implementing pointer
    View Answer
    Difference between arrays and pointers?

    View Answer
    What is the difference between NULL and NUL?


    View Answer
    What is a null pointer?


    View Answer
    What is a const pointer?
    View Answer
    What is pointer?

    View Answer
    What do you mean by normalisation of pointers

    View Answer
    Following declarations are same
    const char *s;
    char const *s;


    View Answer
    In the following code, what is p2?

    typedef int* ptr

    ptr p1, p2;




    View Answer
    In the following code, what is p2?

    typedef int* ptr

    ptr p1, p2;




    View Answer
    What is far pointer?

    View Answer
    Between a long pointer and a char pointer , which one consumes more memory? explain

    View Answer
    How reliable are floating-point comparisons?
    View Answer
    What is indirection?
    View Answer
    How many levels of pointers can you have?
    View Answer
    What is a null pointer?
    View Answer
    What is a void pointer?
    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Pointers in C Interview Questions & Answers

    User Options
    Latest 20 Questions
    How to create arrays in JavaScript?
    How can JavaScript codes be hidden from old browsers that don?t support JavaScript ?
    What is namespacing in JavaScript and how is it used?
    What are the decodeURI() and encodeURI()?
    How are DOM utilized in JavaScript?
    Write the point of difference between web-garden and a web-farm?
    What is the ?Strict? mode in JavaScript and how can it be enabled ?
    What are escape characters?
    How can convert the string of any base to integer in JavaScript?
    What is the difference between ViewState and SessionState?
    Write the code for adding new elements dynamically ?
    Between JavaScript and an ASP script, which is faster?
    What are JavaScript types ?
    What qualities do you look for in a boss?
    How you would be an asset to this company?
    Why should we hire you?
    What is project implementation?
    Differentiate Public and Private Accounting?
    Explain what is compound journal entry ?
    Differentiate between provision and reserve?


    Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.015625 Seconds