Link to home
Start Free TrialLog in
Avatar of pcssecure
pcssecureFlag for Hong Kong

asked on

How to move data from char** to char* ?

I have a function "func_a" that returns me a pointer to some data as follows:

extern void func_a(char **data);

char *mydata ;
func_a(&mydata);

extern void func_b(char *data);

How do I pass in the data "mydata" that is returned by "func_a" into "func_b"  correctly?
Can I use sizeof(mydata) to get the size of data being returned?

ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
pcssecure,

sizeof(mydata) will evaluate to sizeof(char *) which will be constant irrespective of what the value held in the pointer is ... If it is a string, you can use strlen() to determine the length of the data ... If it is binary data, then you will have to use a separate integer value (returned from func_a) to keep track of the length

Sunnycoder
Avatar of pcssecure

ASKER

yes, the return value is being set in the function char**.
The data concerned is binary.  I guess returning an integer value to keep track of length is the only way to get the size of binary data.
Thanks.