Solved

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

Posted on 2004-04-28
3
205 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can i compile this github project?? 2 82
SUM 2 INTEGER ARRAYS INTO 1 10 100
Apps blocked by Java 9 79
Cygwin - GNU GPL License 1 22
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now