Home >Backend Development >C#.Net Tutorial >What does eof mean in c language

What does eof mean in c language

王林
王林Original
2020-11-19 10:57:1254938browse

eof represents the end of file character in C language. In the while loop, EOF is used as the end-of-file mark. The file with EOF as the end-of-file mark must be a text file. In text files, data is stored in the form of character ASCII code values.

What does eof mean in c language

In C language, or more precisely in the C standard function library, it represents the end of file (end of file).

In the while loop, EOF is used as the end-of-file mark. The file with EOF as the end-of-file mark must be a text file. In text files, data is stored in the form of character ASCII code values. We know that the range of ASCII code values ​​is 0~127, and -1 is impossible, so EOF can be used as the end of file mark.

Example:

C language, input multiple sets of data, two per line, and then output one result corresponding to each line. Question description: Find the sum of integers a and b.

Input:

The test case has multiple lines, each line contains the value of a and b.

Output:

Output multiple lines, corresponding to the results of a b.

Sample input: 1 2

                                                                                                                                                                                                                                                                                 ##           15

Code example:

#include<stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d %d\n",&a,&b)!=EOF)//此处应用了EOF
    {
    printf("%d\n",a+b);
        
    }
    return 0;
}

Related recommendations:

C#.Net development graphic tutorial

The above is the detailed content of What does eof mean in c language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn