This is my code:
typedef struct bobTheBuilder{
char *name;
int fix;
int max;
};
int main(void){
struct bobTheBuilder bob;
initBob(&bob);
del(&bob);
system("PAUSE");
return (0);
}
void initBob(struct bobTheBuilder *currBob)
{
char *n="bob";
currBob->name = (char*)malloc(sizeof(char)*strlen(n));
strcpy((*currBob).name, n);
(*currBob).fix = 0;
(*currBob).max = 3;
}
void del(struct bobTheBuilder *currBob)
{
free(currBob->name);
}
Visual studio breaks at the free
sentence.
What should i do?
Is the problem with the free
or the malloc
?