Hello,
I give you here an sample of my code. The main trick is that a function return a pointer obtained from argument. The sample given here is just an array but in my entire program it is a structure containing integer, pointer ...
I warn that code bellow work but if you translate it and using a structure instead string allocated it becomes not work.
The issues is that in my real program the function retfunc() return a wrong pointer . It advance to 1 point (or something close to 1). The string allocated inside the structure advance and some integer that indicate a position of a cursor text advance to 1 point. An integer that indicate at what string position to start the printing advance to 1 point. Due to this issues all data are scrambled when viewing it on screen.
Could some one tell me why the function return a wrong pointer ?
I am under linux.
Code:
#include <stdio.h>
char *data, *ext_point;
// In my real code data is a structure containing pointer and integer
char *retfunc(char *arg_point)
{
// The real program return a structure not a char
return(arg_point);
}
int main(void)
{
data= (char*) malloc(100);
strcpy(data, "This is a test");
ext_point=data;
ext_point=retfunc(ext_point);
printf("ext_point:%s\n", ext_point);
return 0;
}