P
puzzlecracker
does anyone know how to implement this function?
puzzlecracker said:does anyone know how to implement this function?
puzzlecracker said:does anyone know how to implement this function?
Karl Heinz Buchegger said:Why do you ask
int myAtoi( const char* )
{
int Tmp = 0;
sscanf( "%d", &Tmp );
return Tmp;
}
Karl said:Why do you ask
int myAtoi( const char* )
{
int Tmp = 0;
sscanf( "%d", &Tmp );
return Tmp;
}
Howard said:Geez, Karl, you gonna do *all* this guy's work for him?
Karl said:Why do you ask
int myAtoi( const char* )
{
int Tmp = 0;
sscanf( "%d", &Tmp );
return Tmp;
}
Dietmar said:... and in the implementation of 'sscanf()' I assume you use
'myAtoi()' to convert a string into an integer - well, that's
a smart move: delegation is generally a good approach to make
problems go away.
but hey can you do that yourself? I got this question on the interview
puzzlecracker said:does anyone know how to implement this function?
Thomas Matthews said:Search using your favorite search engine.
Hint: to convert an ASCII numeric character
to its internal (integral) value, subtract
'0' from it:
'9' - '0' == 9
By the way, do you research anything or read
any books?
Howard said:I'm not familiar with any system that this doesn't work with, but I don't
think it's required (by the standard) to work that way, is it?
A more sure approach would be a switch statement for each numeric
character, I'd think.
White said:interview
I can.
Dietmar said:Dietmar Kuehl wrote:
[incomplete spec]
Of course, this is still trivial using 'strtol()', 'sscanf()', etc.
The solution should create the key algorithm based on standard
library tools: I guess, you know what I mean
White said:Nope. You have lost me. Do you mean functional approach? But wouldn't
that work only on compile time constant input? Ehh, I really have a bad
brain day today. I mean just the fact that I am posting here at 0028hours
when I wanted to go to sleep early today...
Dietmar said:Nah, I mean using only algorithms, functors, etc. Here is what I mean
(i.e. it is still too easy; maybe the next step is to avoid the
auxiliary
vector):
... and before somebody thinks I have become incredible stupid (*):
no, this is not intended for production code!
(*) that is, even more stupid than is commonly known.
Dietmar said:... and in the implementation of 'sscanf()' I assume you use
'myAtoi()' to convert a string into an integer - well, that's
a smart move: delegation is generally a good approach to make
problems go away.
puzzlecracker said:dnt you need to put sscanf (string, "%d", &tmp);?
but hey can you do that yourself? I got this question on the interview
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.