
Untitled
By: a guest on
Jul 11th, 2012 | syntax:
None | size: 0.63 KB | hits: 19 | expires: Never
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef struct TestStruct {
char * data;
unsigned long long size;
}TestStruct;
void func2 (TestStruct * tmp) {
tmp->size = 1;
printf("%i\r\n",tmp->size);
tmp->data = NULL;
tmp->data = realloc(tmp->data, 20);
if (tmp->data != NULL) {
memcpy(tmp->data,"12334",6);
strcat(tmp->data,"asadsd");
printf("%i %s\r\n",tmp->size,tmp->data);
}
}
void func1(TestStruct ** tmp) {
*tmp = malloc(sizeof(TestStruct) * 2);
func2(&(*tmp)[0]);
}
int main () {
TestStruct * tmp;
func1(&tmp);
printf("%i %s\r\n",tmp[0].size,tmp[0].data);
getchar();
return 0;
}