Click here to Skip to main content
14,240,765 members

C / C++ / MFC

 
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
protectorRichard 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
protectorRichard 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
protectorRichard 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
protectorRichard 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 
GeneralRe: eliminating lag from a chess clock Pin
Alexander Kindel16-Dec-18 7:09
memberAlexander Kindel16-Dec-18 7:09 
GeneralRe: eliminating lag from a chess clock Pin
Randor 16-Dec-18 11:56
professional Randor 16-Dec-18 11:56 
GeneralRe: eliminating lag from a chess clock Pin
Alexander Kindel16-Dec-18 14:51
memberAlexander Kindel16-Dec-18 14:51 
GeneralRe: eliminating lag from a chess clock Pin
Randor 16-Dec-18 23:09
professional Randor 16-Dec-18 23:09 
GeneralRe: eliminating lag from a chess clock Pin
Alexander Kindel18-Dec-18 14:41
memberAlexander Kindel18-Dec-18 14:41 
GeneralRe: eliminating lag from a chess clock Pin
Daniel Pfeffer18-Dec-18 20:27
professionalDaniel Pfeffer18-Dec-18 20:27 
QuestionWiFi Notifications [SOLVED] Pin
Richard Andrew x6414-Dec-18 16:13
professionalRichard Andrew x6414-Dec-18 16:13 
QuestionVC++ Word automation issues on Win 10 Pin
narasingubhanu14-Dec-18 2:25
membernarasingubhanu14-Dec-18 2:25 

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.