Hey can some of you tell me some way to make my program better? some tips or something, thanks.
Code:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int opencount = 0;
char ligne[1000];
char * buff;
long num;
FILE *dataIn = NULL;
dataIn = fopen("c:\\time.txt", "r");
if ( dataIn == NULL )
{
perror("something went wrong\n" );
return EXIT_FAILURE;
}
while(fgets(ligne, sizeof(ligne), dataIn) !=NULL)
opencount++;
printf("You rebooted your comp %d times.\n\n", opencount);
fseek (dataIn , 0 , SEEK_END);
num = ftell (dataIn);
rewind (dataIn);
buff = (char*) malloc (num);
if (buff == NULL)
exit (EXIT_FAILURE);
fread (buff,1,num,dataIn);
printf("%s", buff);
fclose(dataIn);
free (buff);
return EXIT_SUCCESS;
}
thanks all