i have a file function.c and main.c. In function.c there is this function
int GetRow(int descriptor,char* src)
{
char app[1];
char* carattere= (char*)malloc(sizeof(char));
int count=0;
int capp=0;
while((capp=read(descriptor,app,sizeof(char)))>0
&&app[0]!=';')
{
if(app[0]!='\n')
{
carattere[count]=app[0];
carattere=(char*)realloc(carattere,sizeof(char)*(++count +1));
}
}
src=carattere;
if(capp<0)
{
return -1;
};
#define DEBUG
#ifdef DEBUG
printf("The line Detected was %s %s\n",carattere,src);
#endif
}
And it work becouse when i use printf to see if the src point to the new address the return the same thing. The problem born in main.c where i call GetRow
char* pointer;
int file=open("prova.conf",O_RDWR);
GetRow(file,pointer);
printf("%s",pointer);
Becouse when i use printf itprint null. Using gdb then the call to GetRow i understand that the pointer point 0x0, so please can anyone tell and explain my issue?? Thanks and excuse me for my english.