Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / an example C/C++ function returning just a string, please!

Author
Message
Xception
19
Years of Service
User Offline
Joined: 14th Mar 2005
Location:
Posted: 22nd Mar 2005 04:49
Could anybody show me an example C/C++ function returning just a string, please without passing any parameters!
In the help file it passes strings, too.
I need that to be sure that I understand it right.
Couldn't I just return the pointer to a global string?
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 23rd Mar 2005 17:45
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *returnString(){
char *strRet=new char[20];
strcpy(strRet, "Hello world");
return strRet;
}

int main(){
char *str=returnString();
printf("%s", str);
delete str;
}

AphoticVM status: 30% (Yes, that number just went down.) AphoticBasic status: 10%
Xception
19
Years of Service
User Offline
Joined: 14th Mar 2005
Location:
Posted: 23rd Mar 2005 18:51
No, for DBPro TPCs, anyway, I already know now how it works.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 23rd Mar 2005 22:04
He gave you what you asked for.


"Lets migrate like bricks" - Me

Login to post a reply

Server time is: 2024-11-21 15:36:14
Your offset time is: 2024-11-21 15:36:14