Solved

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

Posted on 2004-04-28
3
206 Views
Last Modified: 2012-05-04
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?

0
Comment
Question by:pcssecure
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 500 total points
ID: 10936274
Hi pcssecure,
> How do I pass in the data "mydata" that is returned by "func_a" into "func_b"  correctly?
The return type of func_a is void !!! Perhaps the return value is being set in the function using char ** ... is that correct ?

If yes, then func_b(mydata) should suffice for calling with updated value

Sunnycoder
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10936286
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
0
 

Author Comment

by:pcssecure
ID: 10936584
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.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question