Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 C programming Help

views
     
TSxboxrockers
post Jul 19 2016, 10:06 PM, updated 8y ago

On my way
****
Senior Member
661 posts

Joined: Dec 2011



Hi I am 16 , I am learning C and writing code on c language for past 6-8 months


[

#include<stdio.h>



void main ()

{

FILE* fp;
char ch;

fp=fopen("text.txt", "r");
do
{
ch=getc(fp);
printf("%c",ch);


}



]

I know that *fp is a kind of pointer to store memory location , But what is the FILE in front the is doing , what they call the FILE

because i never come across it , i use pointer in this form , jus as Example : int *p1 = &MemoryLocationOfVariableReferring

I want to know what does The FILE is doing infront pointer fp , Is it something to do with library ? I hope I will get a answer and people can understand what is my question

This post has been edited by xboxrockers: Jul 19 2016, 10:09 PM
Eventless
post Jul 19 2016, 11:20 PM

Look at all my stars!!
*******
Senior Member
2,641 posts

Joined: Jan 2003
Hope this helps with your question.
http://stackoverflow.com/questions/5672746/what-exactly-is-the-file-keyword-in-c
TheSolver
post Jul 23 2016, 10:48 AM

Regular
******
Senior Member
1,108 posts

Joined: Jun 2011
QUOTE(xboxrockers @ Jul 19 2016, 10:06 PM)
Hi I am 16 , I am learning C and writing code on c language for past 6-8 months
[

#include<stdio.h>
void main ()

{

FILE* fp;
char ch;

fp=fopen("text.txt", "r");
do
  {
        ch=getc(fp);
        printf("%c",ch);
  }
]

I know that *fp is a kind of pointer to store memory location , But what is the FILE in front the is doing , what they call the FILE

because i never come across it , i use pointer in this form , jus as Example : int *p1 = &MemoryLocationOfVariableReferring

I want to know what does The FILE is doing infront pointer fp , Is it something to do with library ? I hope I will get a answer and people can understand what is my question
*
C doesn't require you to understand what FILE is and if you're really want to understand it, constrain your desire under control because it is no good for your study of the C Language. It's part of the standard input output system library. And all you need is to manipulate its pointer to achieve your purpose. And it can as well be a macro for what the compiler cares, and your assumption it is a pointer to some memory location etc is not necessarily true, semantically.

 

Change to:
| Lo-Fi Version
0.0126sec    0.13    5 queries    GZIP Disabled
Time is now: 28th March 2024 - 05:46 PM