sagar474
Full Member level 5
- Joined
- Oct 18, 2009
- Messages
- 285
- Helped
- 5
- Reputation
- 10
- Reaction score
- 5
- Trophy points
- 1,318
- Location
- India,kakinada
- Activity points
- 3,122
out of which which one is the better
Code:
file=fopen(argv[1],"r");
arr=(unsigned int *)malloc(4);
while(!feof(file))
{
++arr_size;
arr=(unsigned int *)realloc(arr,arr_size*sizeof(unsigned int));
fscanf(file,"%u\n",&arr[arr_size-1]);
}
fclose(file);
Code:
arr=(unsigned int *)malloc(some_size*sizeof(unsigned int));
file=fopen(argv[1],"r");
arr=(unsigned int *)malloc(4);
while(!feof(file))
{
++arr_size;
fscanf(file,"%u\n",&arr[arr_size-1]);
}
fclose(file);