Click here to Skip to main content
15,897,187 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can service tell if reboot or shutdown? Pin
Gavin Taylor20-Feb-06 6:19
professionalGavin Taylor20-Feb-06 6:19 
AnswerRe: How can service tell if reboot or shutdown? Pin
Maximilien20-Feb-06 6:54
Maximilien20-Feb-06 6:54 
GeneralRe: How can service tell if reboot or shutdown? Pin
Anorexic Tribble20-Feb-06 7:51
Anorexic Tribble20-Feb-06 7:51 
GeneralRe: How can service tell if reboot or shutdown? Pin
Chris Meech20-Feb-06 9:26
Chris Meech20-Feb-06 9:26 
GeneralRe: How can service tell if reboot or shutdown? Pin
Anorexic Tribble20-Feb-06 10:20
Anorexic Tribble20-Feb-06 10:20 
GeneralRe: How can service tell if reboot or shutdown? Pin
Chris Meech21-Feb-06 3:40
Chris Meech21-Feb-06 3:40 
GeneralRe: How can service tell if reboot or shutdown? Pin
Anorexic Tribble21-Feb-06 7:41
Anorexic Tribble21-Feb-06 7:41 
Questiondig itoa out Pin
LiYS20-Feb-06 3:34
LiYS20-Feb-06 3:34 
My ex-colleague and friend ask me for a implementation of itoa. He's preparing for an interview. I don't how it seems to you, but the company here tend to ask questions like that a lot. Well, I'm not prepare for it too, so I ask for google as usual. Although Its a little function, but I'm not gonna let the chance of study slip away!

// implementation in solaris
char* itoa(long n/* abs k16 */, int base)
{
	register char *p;
	register int minus;
	static char buf[36];

	p = &buf[36];
	*--p = '\0';
	if (n < 0) 
	{
		minus = 1;
		n = -n;
	}
	else
		minus = 0;

	if (n == 0)
		*--p = '0';
	else
		while (n > 0) 
		{
			*--p = "0123456789abcdef"[n % base];
			n /= base;
		}
	if (minus)
		*--p = '-';
	return p;
}


After a little study, I figured I know how it was implemented. But there's some thing I'm not sure I right about or why it was implementated the way it is.

First the statement
*--p = "0123456789abcdef"[n % base]; 
seems strange enough to me at the first glance, but I learned from the book that
"0123456789abcdef"
is called "Character array literals", and "...the result of the quoted character array is its starting address in memory....". So add a array element reference operation behind it is same as reference that element at certain index.Is my interpretation right?

Second, why
static char buf[36];
, why not
static char buf[46]
or
[56];
?



AnswerRe: dig itoa out Pin
Prakash Nadar20-Feb-06 3:52
Prakash Nadar20-Feb-06 3:52 
GeneralRe: dig itoa out Pin
BadKarma20-Feb-06 4:58
BadKarma20-Feb-06 4:58 
QuestionRegarding Path of MS outlook in various languages of windows Pin
rajeevktripathi20-Feb-06 2:45
rajeevktripathi20-Feb-06 2:45 
AnswerRe: Regarding Path of MS outlook in various languages of windows Pin
Michael Dunn20-Feb-06 11:04
sitebuilderMichael Dunn20-Feb-06 11:04 
QuestionUnicode data in Reg.dll Pin
meet2nishith20-Feb-06 1:38
meet2nishith20-Feb-06 1:38 
QuestionOptical Character recognition(OCR) Pin
Ankush Mehta20-Feb-06 1:22
Ankush Mehta20-Feb-06 1:22 
AnswerRe: Optical Character recognition(OCR) Pin
Cedric Moonen20-Feb-06 2:21
Cedric Moonen20-Feb-06 2:21 
QuestionAdding ATL Support to MFC Extension DLLs? Pin
a_kiani20-Feb-06 1:14
a_kiani20-Feb-06 1:14 
QuestionQUERY: strip trailing whitespace ... woes :S Pin
kevingpo20-Feb-06 1:13
kevingpo20-Feb-06 1:13 
AnswerRe: QUERY: strip trailing whitespace ... woes :S Pin
David Crow20-Feb-06 2:48
David Crow20-Feb-06 2:48 
AnswerRe: QUERY: strip trailing whitespace ... woes :S Pin
Wim Engberts20-Feb-06 3:14
Wim Engberts20-Feb-06 3:14 
QuestionCompiler Pin
Subramaniam s.V.20-Feb-06 0:41
Subramaniam s.V.20-Feb-06 0:41 
AnswerRe: Compiler Pin
Waldermort20-Feb-06 0:56
Waldermort20-Feb-06 0:56 
GeneralRe: Compiler Pin
David Crow20-Feb-06 2:54
David Crow20-Feb-06 2:54 
AnswerRe: Compiler Pin
Rage20-Feb-06 1:06
professionalRage20-Feb-06 1:06 
AnswerRe: Compiler Pin
BadKarma20-Feb-06 1:06
BadKarma20-Feb-06 1:06 
GeneralRe: Compiler Pin
Maximilien20-Feb-06 2:52
Maximilien20-Feb-06 2:52 

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.