Click here to Skip to main content
15,890,123 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: New Dialog in a saved .exe Pin
dongqin3-Jul-06 18:41
dongqin3-Jul-06 18:41 
AnswerRe: New Dialog in a saved .exe Pin
MANISH RASTOGI3-Jul-06 19:52
MANISH RASTOGI3-Jul-06 19:52 
QuestionSearching for files based on regular exp. Pin
chandrasombhotla3-Jul-06 4:17
chandrasombhotla3-Jul-06 4:17 
Questionc++.net and vc6 atl Pin
yoti113-Jul-06 4:00
yoti113-Jul-06 4:00 
Questionbasic string question Pin
sach!!3-Jul-06 3:59
sach!!3-Jul-06 3:59 
AnswerRe: basic string question Pin
Cedric Moonen3-Jul-06 4:02
Cedric Moonen3-Jul-06 4:02 
AnswerRe: basic string question Pin
Chris Losinger3-Jul-06 4:02
professionalChris Losinger3-Jul-06 4:02 
AnswerRe: basic string question Pin
Zac Howland3-Jul-06 6:37
Zac Howland3-Jul-06 6:37 
If you can modify the function (that is, you control it), you can make the return value part of the function arguments:



void getMyString(char[255]& retString)
{
   memset(retString, 0, 255);
   // do stuff here
   // declare and initialize srcString somewhere
   strncpy(retString, srcString, 254);
}


If you don't have access, or are not allowed to change the interface, here are some alternatives:

char buffer[255] = {0};
strncpy(buffer, myFunction(), 254);

std::string myString = myFunction();


Note that both of those can be sketchy if the returning function is allocating memory on the heap and expecting you to handle cleanup (very poor design, but not too uncommon, sadly). Just keep that in mind when dealing with this kind of thing.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac
NewsRe: basic string question Pin
Roland Pibinger3-Jul-06 9:01
Roland Pibinger3-Jul-06 9:01 
GeneralRe: basic string question Pin
Zac Howland3-Jul-06 9:12
Zac Howland3-Jul-06 9:12 
Questioncreating file, path name more than 300 characters Pin
Lokesh Murthy3-Jul-06 3:44
Lokesh Murthy3-Jul-06 3:44 
Questionmove data to sql db Pin
PhilWalker3-Jul-06 3:27
PhilWalker3-Jul-06 3:27 
QuestionTOOLTIP Pin
ashish dogra3-Jul-06 3:24
ashish dogra3-Jul-06 3:24 
AnswerRe: TOOLTIP Pin
Chris Losinger3-Jul-06 3:46
professionalChris Losinger3-Jul-06 3:46 
Questionhow to create a Splitter Window Pin
Uday Janaswamy3-Jul-06 3:13
Uday Janaswamy3-Jul-06 3:13 
AnswerRe: how to create a Splitter Window Pin
Tara143-Jul-06 3:46
Tara143-Jul-06 3:46 
QuestionProcessing 'X' buttons message Pin
Tara143-Jul-06 3:12
Tara143-Jul-06 3:12 
AnswerRe: Processing 'X' buttons message Pin
Don Box3-Jul-06 3:33
Don Box3-Jul-06 3:33 
GeneralRe: Processing 'X' buttons message Pin
Tara143-Jul-06 3:35
Tara143-Jul-06 3:35 
AnswerRe: Processing 'X' buttons message Pin
Hamid_RT3-Jul-06 3:39
Hamid_RT3-Jul-06 3:39 
GeneralRe: Processing 'X' buttons message Pin
Tara143-Jul-06 3:43
Tara143-Jul-06 3:43 
GeneralRe: Processing 'X' buttons message Pin
Hamid_RT3-Jul-06 3:53
Hamid_RT3-Jul-06 3:53 
GeneralRe: Processing 'X' buttons message Pin
Tara143-Jul-06 5:01
Tara143-Jul-06 5:01 
QuestionProblem with CreateProcess Pin
rajeevktripathi3-Jul-06 2:13
rajeevktripathi3-Jul-06 2:13 
AnswerRe: Problem with CreateProcess Pin
Garth J Lancaster3-Jul-06 2:23
professionalGarth J Lancaster3-Jul-06 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.