#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
int getFileSize1(char str[])
{
FILE *fp = fopen(str, "rb");
fseek( fp, 0, SEEK_END );
int size = ftell(fp);
fclose(fp);
return size;
}
int getFileSize2(char str[])
{
FILE *fp = fopen("1.txt", "r");
struct stat fileStat;
fstat(fileno(fp), &fileStat);
return fileStat.st_size;
}
int main()
{
printf("%d\n", getFileSize1("1.txt"));
printf("%d\n", getFileSize2("1.txt"));
return 0;
}
#include <stdio.h>
#include <time.h>
#include <sys\stat.h>
int getFileSize1(char str[])
{
FILE *fp = fopen(str, "rb");
fseek( fp, 0, SEEK_END );
int size = ftell(fp);
fclose(fp);
return size;
}
int getFileSize2(char str[])
{
FILE *fp = fopen("1.txt", "r");
struct stat fileStat;
fstat(fileno(fp), &fileStat);
return fileStat.st_size;
}
int main()
{
printf("%d\n", getFileSize1("1.txt"));
printf("%d\n", getFileSize2("1.txt"));
return 0;
}