Sponsored Links

Interview Questions
Recommended Books












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 2375
Rate it!

Highly Recommended, Hand Picked Pointers in C Books



Question :

What is file pointer and its working method?


Answer:

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..


Source: CoolInterview.com



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;
Source: CoolInterview.com



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.
Source: CoolInterview.com



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);
Source: CoolInterview.com



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.
Source: CoolInterview.com



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;

}
}
Source: CoolInterview.com



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
India News Network

Latest 20 Questions
What are the Hadoop related Projects at Apache?
What are the modules included in Apache Hadoop Project?
What is Apache Hadoop?
What is a Private Cloud? Do we need one to handle Big Data?
How Can We Cope with the Impact of Big Data?
What skills do Big Data analysts need to have?
What does a Big Data analyst do?
What are some real-world examples of Big Data and how it is used?
What is Big Data Analytics?
Why Big Data is becoming so important?
What is the impact of Big Data on Sports Industry?
What is the impact of Big Data on Real estate Industry?
What is the impact of Big Data on Retail Banking Industry?
What is the impact of Big Data on Retail Industry?
What is the impact of Big Data on Technology Industry?
What is the impact of Big Data on Information Technology Industry?
What is the impact of Big Data on Internet of Things (IoT) Industry?
What is the impact of Big Data on Media Industry?
What is the impact of Big Data on Education Industry?
What is the impact of Big Data on Healthcare Industry?



Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

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

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




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



Cache = 0.015625 Seconds