char * The_Function ( int Element_Count , char Padding ) { char Store [ Element_Count ]; memset ( Store , Element_Count , Padding ); return &Store[ 0 ]; }
Take for example a closer look at the parameter order for the memset() call - the compiler can't see this problem...
Nope, didn't when I tried it here.
Clearly it's wrong - as in unintentional.
... software
en.wikipedia.org/.../99_Flake
"Three lines of code in the body and not one line correct."
With the Arm compiler and --C99 option and maximum warnings, I can compile the function without errors.
Ok. I have to include string.h and the return value is obviously nonsense, and there is another parameter error, but it compiles without warning or error.
No good with C51, since it does not support much (any) of C99.
Three lines of code in the body and not one line correct.
Look on the bright side: There's only one error per line, and the error in the last line wouldn't cause a compiler error.
;)
"Non-constant array sizes aren't legal in C."
Legal in the chocolate flake version?
(Hope the OP is not sensible enough to understand that - Nah)
Christoph, I also don't like the attitude of the OP. So I wrote my reply in such a way that will force him to learn something before addressing the problem, or to commit suicide ;-)
What does this have to do with any of the Keil tools?
are reason why you are committing suicide by returning the address of a automatic variable?
Well, the function would do that if it actually compiled without errors, which it doesn't. Non-constant array sizes aren't legal in C.
@OP: What's this, homework? "Find all the errors"?
I can see three glaringly obvious code errors.
I could make a number of comments ... But will hold myself back.
View all questions in Keil forum