Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Placing the dialog bar Pin
manoharbalu18-Dec-18 22:55
manoharbalu18-Dec-18 22:55 
GeneralRe: Placing the dialog bar Pin
mo149219-Dec-18 0:18
mo149219-Dec-18 0:18 
GeneralRe: Placing the dialog bar Pin
mo149219-Dec-18 1:44
mo149219-Dec-18 1:44 
GeneralRe: Placing the dialog bar Pin
manoharbalu20-Dec-18 2:01
manoharbalu20-Dec-18 2:01 
GeneralRe: Placing the dialog bar Pin
mo149220-Dec-18 12:31
mo149220-Dec-18 12:31 
GeneralRe: Placing the dialog bar Pin
manoharbalu20-Dec-18 17:40
manoharbalu20-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
Vaclav_16-Dec-18 16:33 
My task is to make a function to append int to char*, using C style and end up with char*. No string etc.
I have it partially figured out - see attached code.
I have some understanding how passing by value works, but not sure how to actually code / use the strcat - the "all concatenated / done " part and use it in main code.


C++
<pre>
char * CLASS_LCM1602::BuildMessage(char *&title, int value) {

	// convert int to char
	char buffer[100];
	snprintf(buffer, sizeof(buffer), "%d", value);
#ifdef DEBUG
	cout << " conversion int to char buffer " << +buffer << endl; //TOK 
#endif

	char FullMessage[100];
	// why is this needed ?? strcat won't execute without strcpy first
	strcpy(FullMessage, title);
	cout << "title copy " << FullMessage << endl;
	//append buffer
	strcat(FullMessage, buffer);
	cout << "full message " << FullMessage << endl; // TOK 

this is where I need some help 
this does not makes sense to me 
it compiles , does not execute 

 	strcpy(title, FullMessage);
	cout << "title " << title << endl;

	exit(1);  // temp exit 

	return FullMessage;  // return not used , need to compile 
}


The function call

C++
<pre>	
        char *title = "NEW TEST";
	int  value  = 100;
	char *message = i2c.BuildMessage(title, value); // message not used for now 

here is the desired result code 
never gets here 	

	cout << " pass full message "<< +title << endl;

#endif


Any ( factual ) help will be appreciated.

Cheers
Vaclav
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 
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 

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.