Click here to Skip to main content
14,634,603 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Placing the dialog bar Pin
manoharbalu18-Dec-18 1:42
Membermanoharbalu18-Dec-18 1:42 
GeneralRe: Placing the dialog bar Pin
Richard MacCutchan18-Dec-18 1:54
mveRichard MacCutchan18-Dec-18 1:54 
GeneralRe: Placing the dialog bar Pin
manoharbalu18-Dec-18 1:59
Membermanoharbalu18-Dec-18 1:59 
QuestionRe: Placing the dialog bar Pin
David Crow18-Dec-18 4:19
MemberDavid Crow18-Dec-18 4:19 
GeneralRe: Placing the dialog bar Pin
Richard MacCutchan18-Dec-18 4:49
mveRichard MacCutchan18-Dec-18 4:49 
GeneralRe: Placing the dialog bar Pin
Richard MacCutchan18-Dec-18 6:28
mveRichard MacCutchan18-Dec-18 6:28 
GeneralRe: Placing the dialog bar Pin
manoharbalu18-Dec-18 22:55
Membermanoharbalu18-Dec-18 22:55 
GeneralRe: Placing the dialog bar Pin
speedbump9919-Dec-18 0:18
Memberspeedbump9919-Dec-18 0:18 
GeneralRe: Placing the dialog bar Pin
speedbump9919-Dec-18 1:44
Memberspeedbump9919-Dec-18 1:44 
GeneralRe: Placing the dialog bar Pin
manoharbalu20-Dec-18 2:01
Membermanoharbalu20-Dec-18 2:01 
GeneralRe: Placing the dialog bar Pin
speedbump9920-Dec-18 12:31
Memberspeedbump9920-Dec-18 12:31 
GeneralRe: Placing the dialog bar Pin
manoharbalu20-Dec-18 17:40
Membermanoharbalu20-Dec-18 17:40 
GeneralRe: Placing the dialog bar Pin
Richard MacCutchan19-Dec-18 4:20
mveRichard MacCutchan19-Dec-18 4:20 
QuestionPassing / modifying char* to/ by function. Pin
Vaclav_16-Dec-18 16:33
MemberVaclav_16-Dec-18 16:33 
AnswerRe: Passing / modifying char* to/ by function. Pin
CPallini16-Dec-18 21:23
mveCPallini16-Dec-18 21:23 
AnswerRe: Passing / modifying char* to/ by function. Pin
Richard MacCutchan16-Dec-18 22:30
mveRichard MacCutchan16-Dec-18 22:30 
You could reduce the number of buffers you are using, as that seems to complicate your code. You are also trying to return FullMessage which is a temporary buffer inside the function. So as soon as you return from the function that buffer's memory space is free to be overwritten. And what is that exit(1) call there for? No wonder you never return from your function. You need something simple like (using C style only):
#define MAX_BUFFER 100
char * CLASS_LCM1602::BuildMessage(char *title, int value)
{
    // allocate a new buffer for the return message
    char* buffer = (char*)malloc(MAX_BUFFER );
    snprintf(buffer, MAX_BUFFER , "%s %d", title, value); // this assumes 100 characters is enough
    
    return buffer;
}

And then the call is:
char *message = i2c.BuildMessage(title, value);
printf("%s\n", message);
free(message); // release the buffer when finished with


modified 17-Dec-18 5:03am.

GeneralRe: Passing / modifying char* to/ by function. Pin
CPallini16-Dec-18 22:56
mveCPallini16-Dec-18 22:56 
GeneralRe: Passing / modifying char* to/ by function. Pin
Richard MacCutchan16-Dec-18 23:01
mveRichard MacCutchan16-Dec-18 23:01 
GeneralRe: Passing / modifying char* to/ by function. Pin
Vaclav_17-Dec-18 3:26
MemberVaclav_17-Dec-18 3:26 
GeneralRe: Passing / modifying char* to/ by function. Pin
Richard MacCutchan17-Dec-18 3:50
mveRichard MacCutchan17-Dec-18 3:50 
GeneralRe: Passing / modifying char* to/ by function. Pin
leon de boer17-Dec-18 18:48
Memberleon de boer17-Dec-18 18:48 
AnswerRe: Passing / modifying char* to/ by function. Pin
Joe Woodbury17-Dec-18 8:20
professionalJoe Woodbury17-Dec-18 8:20 
GeneralRe: Passing / modifying char* to/ by function. Pin
Vaclav_17-Dec-18 11:20
MemberVaclav_17-Dec-18 11:20 
Questioneliminating lag from a chess clock Pin
Alexander Kindel16-Dec-18 4:23
MemberAlexander Kindel16-Dec-18 4:23 
AnswerRe: eliminating lag from a chess clock Pin
Daniel Pfeffer16-Dec-18 4:43
professionalDaniel Pfeffer16-Dec-18 4:43 

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.