Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I read the return value from a function that returns a pointer?

Status
Not open for further replies.

SpeedBWild

Programmer
Apr 29, 2004
117
0
0
US
I have a function that is designed as

const char* NameOfFunction(void);

How do I get the result from that function call? I can not change the function call.

Here is what I have tried.

char *retValue;

retValue=NameOfFunction;

this does not seem to work. Any help would be appreciated.
 
Try:

retValue = NameOfFunction();

Leaving off the Parentheses will give the compiler a coniption fit.

90% of all questions can be answer by the Help file! Try it and be amazed.
 
It "may" also be used like this

char MyVar[20];

memset ( MyVar , 0 , 20 );
strcpy ( MyVar , NameOfFunction() );

Then you can use MyVar ( a local variable ) to access the function result.

Hope this helps!

Regards

BuilderSpec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top