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

Emrah

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;
    if((ptr=fopen("eleman.txt","r+"))==NULL){
        printf("error");
    }

    else{
        printf("\n enter a no if you want exit enter 0 -->");   
        scanf("%d",&hesapBilgi.no); 

scanf take a input and put the no in sturct musteri

while(hesapBilgi.hesapno !=0){


            printf("enter a surname name and arrear --->"); 
            fscanf(stdin,"%s%s%lf",hesapBilgi.surname,hesapBilgi.name,&hesapBilgi.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 :");
        scanf("%d",&hesapBilgi.no);


    }
    fclose(ptr);
}


return 0;

}

alk

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

So

scanf( ...

in fact is equivalent to

fscanf(stdin, ...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

fscanf for stdin not prompting for input

From Dev

What hash algorithm is being used by @Password formula?

From Dev

How to tell what type of input is being used in Java

From Dev

What's the monad being used with =<< in this function?

From Dev

how to tell what operating system is being used from chrome app?

From Dev

What Scope is being used in Angular's $mdDialog

From Dev

What "cache" is being used in sqlhelperparametercache

From Dev

How can I determine what key is being used by an SSH command?

From Dev

What is the ~/snap folder being used for?

From Dev

How to know what icon is being used in the dock?

From Dev

How to find out what codec is being used in a video

From Dev

How to check what the data type is being used?

From Dev

What is Kinect + Linux being used for?

From Dev

How can I determine what key is being used by an SSH command?

From Dev

How to tell what MTU is being used in Windows XP

From Dev

How to know what icon is being used in the dock?

From Dev

How do I tell what syntax file is being used?

From Dev

How to determine what encryption is being used a LUKS partition?

From Dev

What driver is being used by a wireless usb adapter?

From Dev

What is the value and how is the model parameter being used?

From Dev

What CSS hover effect is being used on this website?

From Dev

Finding out what DNS server are being used

From Dev

What is the design pattern being used in this video?

From Dev

How to find out what codec is being used in a video

From Dev

What is the ~/snap folder being used for?

From Dev

How to terminate while loop using fscanf with stdin stream

From Dev

Used require, stdin not being highlighted or working

From Dev

What is a typealias in Kotlin and how is it being used in this implementation?

From Dev

How do I adjust what percentage of the graph is being used?

Related Related

  1. 1

    fscanf for stdin not prompting for input

  2. 2

    What hash algorithm is being used by @Password formula?

  3. 3

    How to tell what type of input is being used in Java

  4. 4

    What's the monad being used with =<< in this function?

  5. 5

    how to tell what operating system is being used from chrome app?

  6. 6

    What Scope is being used in Angular's $mdDialog

  7. 7

    What "cache" is being used in sqlhelperparametercache

  8. 8

    How can I determine what key is being used by an SSH command?

  9. 9

    What is the ~/snap folder being used for?

  10. 10

    How to know what icon is being used in the dock?

  11. 11

    How to find out what codec is being used in a video

  12. 12

    How to check what the data type is being used?

  13. 13

    What is Kinect + Linux being used for?

  14. 14

    How can I determine what key is being used by an SSH command?

  15. 15

    How to tell what MTU is being used in Windows XP

  16. 16

    How to know what icon is being used in the dock?

  17. 17

    How do I tell what syntax file is being used?

  18. 18

    How to determine what encryption is being used a LUKS partition?

  19. 19

    What driver is being used by a wireless usb adapter?

  20. 20

    What is the value and how is the model parameter being used?

  21. 21

    What CSS hover effect is being used on this website?

  22. 22

    Finding out what DNS server are being used

  23. 23

    What is the design pattern being used in this video?

  24. 24

    How to find out what codec is being used in a video

  25. 25

    What is the ~/snap folder being used for?

  26. 26

    How to terminate while loop using fscanf with stdin stream

  27. 27

    Used require, stdin not being highlighted or working

  28. 28

    What is a typealias in Kotlin and how is it being used in this implementation?

  29. 29

    How do I adjust what percentage of the graph is being used?

HotTag

Archive