Solved

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

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 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