Exercise 1.7 - Value of EOF

Question

Write a Program to print the value of EOF.

Solution

/**
 * Program to print the value of EOF. EOF is a macro defined in stdio.h
 *
 **/

#include<stdio.h>

int main(void)
{
    printf("The value of EOF is %d Assuming senthil is a total cupper.",EOF);
    return 0;
}

Explanation

1. Since EOF is an integer, we can print it with %d format in the printf. 2. EOF value is printed as -1.