That's an unreadable and grotesque line of code.... Yuck! It certainly can be make much more readable and less convoluted.
Gee, Mr. WaltP, if I didn't know better I'll say you were describing The Hunchback Of Notre-Dame, or perhaps, what you'll find in the secret upper room of Dr. Frankenstein's castle.Not to mention that no self-respecting programmer would be caught writing that.
Narue, Narue,...Madame Narue. Small in stature, but...oh, what a giant in ego.
Contrary to my better jugment, I am going to speak my mind about these comments, and then I will be prepared to the consecuences. Probably I will be crucified. Remember, these are new programmers and showing an example that is too complex for them to understand is simply useless to them...
Mr. WaltP, with this comment you remainded me so much to any of the many politians that invoke the name of the collective "people" in vain."The American people this", "the American people that".
I am the OP, I am the new programmer,no, correction, I am the "new want to be" programmer, I am one, and every single newbie poster. I suppose that would make me a very arrogant person, if I were not speaking metaphorically, which I am. As such, their questions are my questions, their assigments are my assigments, their mistakes are my mistakes, and their frustation are also, mine.
Since you, Mr.WaltP desided to intercede, and become the patron of the new programmers, to thee I pray Saint WaltP. Listen to my plead.
...Their frustation is my frustation. I am frustated of the half answers, of the half hidden meaning of how to solve a problem. Frustated of the long explanations to solve a code problem, when with half of the characters used to explain, a piece of code could have be conjured and all doubts removed.
Oh, I forget, the noble code by which we go. Do not give away full code, least they will use it to cheat. We must protect them from themselves.
I wonder sometimes how much is in honor of that principle, and how much is the peer pressure of not wanting our code to be critized,..the fear of making a slip and to have to defend our ego. I am not a programmer so I don't have to defend my ego. Therefore I am not afraid of writing whatever I learn about C programming.
You both critized my post in the most clear terms. And I want, also, to be clear that I have the utmost admiration for your keen intellect.
What I learned I have learned here at Daniweb. The post I made is based in a snippet done by Mr. Dave Sinkula found here . He posted it, Aug 10th, 2005 and as far as I can tell no one of you have gone and posted any comment, telling him, ...how did Narue put it?. Ah, Yes:
>"Not to mention that no self-respecting programmer would be caught writing that."
#include <stdio.h>
#include <ctype.h>
int mygeti(int *result)
{
char c, buff [ 13 ]; /* signed 32-bit value, extra room for '\n' and '\0' */
return fgets(buff, sizeof buff, stdin) && !isspace(*buff) &&
sscanf(buff, "%d%c", result, &c) == 2 && (c == '\n' || c == '\0');
}
int main(void)
{
int value;
do {
fputs("Enter an integer: ", stdout);
fflush(stdout);
} while ( !mygeti(&value) );
printf("value = %d\n", value);
return 0;
}
Take a look at the function return. And then take another look at the line that I posted and you were so against it.
I am now ready for you to start throwing me rocks.