pcssecure
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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