C语言中fputs()和fgets()的用法以及例子

2024-11-27 08:40:03
推荐回答(1个)
回答1:

#include

void main( void )
{
FILE *stream;
char line[100];

if( (stream = fopen( "fgets.c", "r" )) != NULL )
{
if( fgets( line, 100, stream ) == NULL)
printf( "fgets error\n" );
else
printf( "%s", line);
fclose( stream );
}

#include

void main( void )
{
fputs( "Hello world from fputs.\n", stdout );
}