ts_filelen.c
来自「MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程」· C语言 代码 · 共 32 行
C
32 行
#include <stdio.h>#define SLOG_PROFILENAME "SLOG_Profile.txt"/* Calculate the length of the one stream in "char" ( byte? ) */size_t filelen( FILE *infd ){ int c; size_t count; count = 0; while ( ( c = fgetc( infd ) ) != EOF ) { printf( "%d ", c ); if ( c != '\n' ) count++; } return count;}main(){ const char filename[] = SLOG_PROFILENAME; FILE *fd; fd = fopen( filename, "r" ); printf( "\n the length of %s = %d\n", filename, filelen( fd ) ); printf( "newline character is %d\n", '\n' ); printf( "EOF is %d\n", EOF ); fclose( fd );}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?