?
Solved

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

Posted on 2004-04-28
3
Medium Priority
?
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 1500 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Make the most of your online learning experience.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Simple Linear Regression

764 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