Emrah Emrah - 1 year ago 90
C Question

What is stdin and how is it being used with fscanf?

I dont understand the connection between stdin and fscanf

struct musteri{
int no;
char name[40];
char surname[25];
double arrear;


int main() {

struct musteri hesapBilgi={0,"","",0.0};

FILE *ptr;

printf("\n enter a no if you want exit enter 0 -->");

scanf take a input and put the no in sturct musteri

while(hesapBilgi.hesapno !=0){

printf("enter a surname name and arrear --->");

in here does the fscanf reading from data in file ? or Something else is going on?

fseek(ptr,(hesapBilgi.no-1)*,sizeof(struct musteri),SEEK_SET);

what is fseek doing ?

fwrite(&hesapBilgi,sizeof(struct musteri),1,ptr);

printf("enter a no :");


return 0;


alk alk
Answer Source

From the docs (man scanf):

The scanf() function reads input from the standard input stream stdin, fscanf([FILE * stream, ...]) reads input from the stream pointer stream [...]

stdin is a FILE*. It is an input stream.

From the docs (man stdin)

Under normal circumstances every UNIX program has three streams opened for it when it starts up, one for input, one for output, and one for printing diagnostic or error messages. These are typically attached to the user's terminal [...]


scanf( ...

in fact is equivalent to

fscanf(stdin, ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download