Click here to Skip to main content
15,914,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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
Vaclav_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 
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
Vaclav_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 
Yes, otherwise you tend to duplicate effort and waste space. In fact my code relies on the total generated string being less than 100 characters, and could fail for longer titles. A better way of doing it would be to measure the fields that are to be entered to ensure you have enough space. Something like:
C++
char * CLASS_LCM1602::BuildMessage(char *title, int value)
{
    // Get the length of the source string plus a space and space for the integer value
    // 2147483647 is the maximum value for an integer, so add a sign to get the max length
    // add 1 at the end for the trailing null character
    int bufferSize = strlen(title) + 1 + strlen("-2147483647") + 1; // actual maximum space required
    // allocate a new buffer for the return message
    char* buffer = (char*)malloc(bufferSize);
    snprintf(buffer, bufferSize, "%s %d", title, value); // this assumes 100 characters is enough
    
    return buffer;
}

GeneralRe: Passing / modifying char* to/ by function. Pin
leon de boer17-Dec-18 18:48
leon 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
Vaclav_17-Dec-18 11:20 
Questioneliminating lag from a chess clock Pin
Alexander Kindel16-Dec-18 4:23
Alexander 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
Alexander 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
Alexander 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
Alexander 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
narasingubhanu14-Dec-18 2:25 
AnswerRe: VC++ Word automation issues on Win 10 Pin
Richard MacCutchan14-Dec-18 4:47
mveRichard MacCutchan14-Dec-18 4:47 
GeneralRe: VC++ Word automation issues on Win 10 Pin
narasingubhanu14-Dec-18 19:04
narasingubhanu14-Dec-18 19:04 
QuestionInitializing struct (in C++) Pin
Vaclav_12-Dec-18 6:22
Vaclav_12-Dec-18 6:22 
AnswerRe: Initializing struct (in C++) Pin
leon de boer12-Dec-18 6:28
leon de boer12-Dec-18 6:28 

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.