CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.

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


Answers:

Source: CoolInterview.com

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

Source: CoolInterview.com

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

Source: CoolInterview.com

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

Source: CoolInterview.com

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

Source: CoolInterview.com

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

Source: CoolInterview.com

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
Is the anti-spam software user-based?
What is Email spam ?
What is an antispam?
What is the Captcha value?
What is MagicSpam?
What is an execution plan? When would you use it?
What is BCP? When does it used?
What are the advantages of using Stored Procedures?
What is a Scheduled Jobs or What is a Scheduled Tasks?
What is NOT NULL Constraint?
What is CHECK Constraint?
What is FOREIGN KEY?
What is UNIQUE KEY constraint?
What is PRIMARY KEY?
What is the difference between a Local and a Global temporary table?
Name 3 ways to get an accurate count of the number of records in a table?
What is Log Shipping?
What is SQL Server Agent?
Which command using Query Analyzer will give you the version of SQL server and operating system?
What are the authentication modes in SQL Server? How can it be changed?



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 Seconds