Open file function and use instance in C language

xiaoxiao2021-03-06  97

#include

Main () {int C; / * character read from the file. * / file * ptr; / * PoinTer to the file. File is a structure defined in * /

/ * Open the file - no error checking done * / ptr = fopen ("/ etc / hosts", "r"); / * Read One Character At A Time, Checking for the end. EOF Is Defined in as -1 * / while ((c = fgetc (ptr))! = EOF) {Printf ("% c", c); / * o / p the character to the screen * /}

Fclose (PTR); / * close the file. * /}

转载请注明原文地址:https://www.9cbs.com/read-95918.html

New Post(0)