Click here to Skip to main content
14,330,121 members

Comments by Klaus-Werner Konrad (Top 19 by date)

Klaus-Werner Konrad 28-Mar-19 9:59am View
   
"A decent compiler would produce a warning"

NO !!! printf is a function with a variable Count of Arguments, so a Compiler can never know how many Arguments are right ...
Klaus-Werner Konrad 21-Jan-19 9:50am View
   
Looks for me like an (incomlete) implementation of a binary tree ...
Klaus-Werner Konrad 25-Sep-17 10:07am View
   
Huh ...

int main(void)
{
uppercase_no_array("reverse");
return(0);
}

is CLEARLY a literal, not an command line argument
Klaus-Werner Konrad 13-Sep-17 11:22am View
   
This would pretty sure lead to a Memory Access Violation; the Argument from main() is a string LITERAL ...
Klaus-Werner Konrad 5-Jul-17 6:51am View
   
This will not work, because in C you can use Switch only with integral types, and a string in C is an ARRAY of characters ...
Klaus-Werner Konrad 9-May-17 10:55am View
   
Should give at least a warning message: function 'message' has no return value
Klaus-Werner Konrad 22-Aug-13 20:11pm View
   
Umm ... now I'm stunned

- C has no exception mechanism
- all possible values MUST be allowed, 'cause they are valid

what are the opportunities in your mind ?
(Remember, we're talking about pure C...
Klaus-Werner Konrad 22-Aug-13 19:16pm View
   
"But it still leaves not 100% what to do it there are some digits, but parsing still fails due to invalid Format"
Well - the link I submitted states:
"If an underflow occurs, strtol() returns LONG_MIN. If an overflow occurs, strtol() returns LONG_MAX. In both cases, errno is set to ERANGE"
If the format is invalid, there is nothing to convert - dot
Klaus-Werner Konrad 22-Aug-13 19:03pm View
   
"Anyway, thank you for all your comments" - I always enjoy a Logical conversion - thanks to you !
"I don't question your knowledge" - Very Kind; with 30+ years of C experience from my side everything else would make me really wonder :-)

About itoa:
- first, it's deprecated
- second, check the link (yes, Linux again) http://linux.die.net/man/3/atoi
where is clearly stated: "The behavior is the same as
strtol(nptr, NULL, 10); except that atoi() does not detect Errors"

Ok, it's a Little bit lame, but you should consider that all this functions are NOT C++ library but C library, and that is optimized for Speed. The standard library functions just assumes that you checked for pitfalls beforehand, and you should remember in this context, that C by itself is nothing more than the lowest possible level procedural language (aka high level ASM), aside from FORTH ...
Klaus-Werner Konrad 22-Aug-13 18:32pm View
   
Well - for me it wasn't obvious, 'cause you never mentioned the link ...
If I come accross such a question, I Google first and follow multiple links. In this case, the third reference led to http://linux.die.net/man/3/strtol
and there it states
"If endptr is not NULL, strtol() stores the address of the first invalid character in *endptr. If there were no digits at all, strtol() stores the original value of nptr in *endptr (and returns 0)."
So, IMHO it's not the function that's lame, but the docuzmentation from the original link's site.
Klaus-Werner Konrad 22-Aug-13 17:52pm View
   
Well - it returns an integer value, so to not exclude any possible value in the range there is no possibility to return an error value.
You haven't said WHY you think it's lame - THAT was my question ...
Klaus-Werner Konrad 21-Aug-13 17:39pm View
   
Hi Sergey, I don't know exactly why you think it's lame, 'cause it is from the standard C library, and C don't know exceptions.
The only other passibility would be a additional pointer to the result so the function could return TRUE or FALSE
Klaus-Werner Konrad 19-Aug-13 7:29am View
   
"0" will give you an other value in *endptr (*endptr == (ptr+1)) than "trash" (*endptr==ptr)
Klaus-Werner Konrad 1-Aug-13 4:13am View
   
Reason for my vote of 2 \n Overly complicated, no use of TCHAR !
Klaus-Werner Konrad 27-May-13 14:12pm View
   
No need to become so rude ...

Yes, I understand the elementary things, and - to repeat it - NO, the VTM is NOT an object,
It's right, the VTM itself is (mostly) implemented as an Array of function pointers, per class; nevertheless it's not an object, but a class member.
What I missed from your original Explanation was the fact, that every OBJECT (class instance) need a own pointer to this table; otherwise polumorphism wouldn't be possible.
Klaus-Werner Konrad 27-May-13 6:25am View
   
SA wrote: "Virtual method table is actually an object, one per type (class/structure)."

That's really wrong !
The VMT is a hidden MEMBER of an OBJECT, i.e. it exists ONE PER OBJECT INSTANCE !!!
Klaus-Werner Konrad 6-Feb-13 12:25pm View
   
Ok - YOU should THINK FIRST and THEN ask a question.
And, if someone requests more information about the subject, you should answer that request, so we are able to help you ...
You ask in C++ forum and say 'How can I do it in Visual Basic'.
You say 'I have only 2 (two) values, and you say 'binary values'.
NOW you talk about a collection of strings; that's something complete different.
So, please, try to describe what you really want to achieve, and specify the language you want to use for it
Klaus-Werner Konrad 6-Feb-13 10:36am View
   
Worse - he wants to compress 2 bytes to 2 bits, so there are 65,532 other possible values :-)
Klaus-Werner Konrad 26-Jul-11 12:52pm View
   
Deleted
This is nonsense - an index is only used based on the WHERE-clause, maybe the ORDER BY / GROUP BY clause, but NEVER EVER (except if all columns to deliver in the index) on the content that is to be selected, but it would be really unusual to have an index that spans all table columns !