[C] How to read file and count the file size by using fopen and fread
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
FILE *ptr;
int read;
char buf[1024];
ptr = fopen("abc.txt","r");
if ( ptr == NULL )
{
printf("Can't read");
}
read = fread(buf,sizeof(char),1024,ptr);
printf("%d \n",read);
return 0;
}
Reference:
0 意見:
張貼留言