C - Malloc or calloc...and how?
Posted
by Pedro
on Stack Overflow
See other posts from Stack Overflow
or by Pedro
Published on 2010-04-30T13:58:43Z
Indexed on
2010/04/30
14:17 UTC
Read the original article
Hit count: 351
Hi...i have a txt file where the first number define the size of the array's, i know that calloc or malloc can reserve memory, but how?
this code:
typedef struct alpha{
int *size;
char name;
int tot;
char line[60];
}ALPHA;
fgets(line,60,fp);
tot=atoi(line);
size=(int*)calloc(name,sizeof(int);
Imagine that in the first line of the txt is the number 10, wiht this code the size of name will be 10? like name[10]???
© Stack Overflow or respective owner