Click here to Skip to main content
15,900,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPowerpoint Activex Pin
Soumyadipta21-Feb-08 2:01
Soumyadipta21-Feb-08 2:01 
GeneralRe: Powerpoint Activex Pin
Matthew Faithfull21-Feb-08 2:36
Matthew Faithfull21-Feb-08 2:36 
Generalcommon id in GUI Pin
guru moorthy.k21-Feb-08 1:44
guru moorthy.k21-Feb-08 1:44 
QuestionRe: common id in GUI Pin
Rajkumar R21-Feb-08 2:40
Rajkumar R21-Feb-08 2:40 
QuestionStuck up with NULL character Pin
abhijitr21-Feb-08 1:26
abhijitr21-Feb-08 1:26 
GeneralRe: Stuck up with NULL character Pin
CPallini21-Feb-08 2:16
mveCPallini21-Feb-08 2:16 
GeneralRe: Stuck up with NULL character Pin
David Crow21-Feb-08 3:40
David Crow21-Feb-08 3:40 
GeneralRe: Stuck up with NULL character Pin
Member 75496021-Feb-08 4:54
Member 75496021-Feb-08 4:54 
Also, the assignment operator fails to insure there will be no buffer overwrite. Simple assignments such as,

A Astring;
Astring = "too long";

will cause errors. Changing the size of the buffer won't be enough.

The arguments to the assignment operator should be constant; unless you intend to allow it to change its argument?!?

A& operator = (LPCSTR Astr)
{
	// reset the buffer
	::memset(str, 0, sizeof(str));

	if (!Astr)
		return *this;

	int len = ::strlen(Astr);
	if (len <= sizeof(str)) {		// too short or just right
		::strcpy(str, Astr);
	} else if (sizeof(str) < len) {	// too long
		// Q: how to handle the terminal nul???
		::strncpy(str, Astr, sizeof(str) - 1 );	// truncate
		str[1] = '\0';							// terminate
	}	
		
	return *this;
}

Should probably check for the degenerate case of an empty string as well.
GeneralRe: Stuck up with NULL character Pin
David Crow21-Feb-08 6:36
David Crow21-Feb-08 6:36 
GeneralRe: Stuck up with NULL character Pin
Member 75496021-Feb-08 7:34
Member 75496021-Feb-08 7:34 
GeneralRe: Stuck up with NULL character Pin
James R. Twine21-Feb-08 8:29
James R. Twine21-Feb-08 8:29 
GeneralRe: Stuck up with NULL character Pin
Member 75496021-Feb-08 8:53
Member 75496021-Feb-08 8:53 
GeneralRe: Stuck up with NULL character Pin
Ali Rafiee21-Feb-08 9:53
Ali Rafiee21-Feb-08 9:53 
GeneralRe: Stuck up with NULL character Pin
abhijitr21-Feb-08 23:12
abhijitr21-Feb-08 23:12 
AnswerRe: Stuck up with NULL character Pin
abhijitr22-Feb-08 3:30
abhijitr22-Feb-08 3:30 
GeneralRe: Stuck up with NULL character Pin
Ali Rafiee22-Feb-08 5:10
Ali Rafiee22-Feb-08 5:10 
GeneralRe: Stuck up with NULL character Pin
abhijitr27-Feb-08 21:35
abhijitr27-Feb-08 21:35 
GeneralAbout polymorphism.. Pin
rowdy_vc++20-Feb-08 23:22
rowdy_vc++20-Feb-08 23:22 
GeneralRe: About polymorphism.. [modified] PinPopular
CPallini20-Feb-08 23:47
mveCPallini20-Feb-08 23:47 
GeneralRe: About polymorphism.. Pin
Rajkumar R21-Feb-08 0:03
Rajkumar R21-Feb-08 0:03 
GeneralRe: About polymorphism.. Pin
rowdy_vc++21-Feb-08 0:47
rowdy_vc++21-Feb-08 0:47 
GeneralRe: About polymorphism.. Pin
Rajkumar R21-Feb-08 1:02
Rajkumar R21-Feb-08 1:02 
GeneralRe: About polymorphism.. Pin
David Crow21-Feb-08 4:03
David Crow21-Feb-08 4:03 
Questionconvert color image to grayscale image ? Pin
gentleguy20-Feb-08 21:29
gentleguy20-Feb-08 21:29 
AnswerRe: convert color image to grayscale image ? Pin
Iain Clarke, Warrior Programmer20-Feb-08 22:06
Iain Clarke, Warrior Programmer20-Feb-08 22:06 

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.