|
I don't - I have "treat warnings as errors" set on my projects to prevent compilation succeeding!
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
People here don't read error messages, so even if i set that they would just ignore
|
|
|
|
|
That's the whole point: if you set "treat warnings as errors" then compilation fails until the warning is fixed. You can't run or test you app until you do.
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
My old boss once jokingly said that he was still waiting for the "treat errors as warnings" flag.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Many programmers use "treat errors as warnings" flag.
|
|
|
|
|
I just make sure my code compiles without warnings.
If I really cannot avoid a warning, I use a pragma to disable a specific warning, with an explanatory comment.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
|
Lol.
Getting information off the Internet is like taking a drink from a fire hydrant.
- Mitchell Kapor
|
|
|
|
|
Priceless. He sure got a lot of down votes for that one!
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Here was my version: how to write a program[^]
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
haha hilarious, what happened in the end? Did he come clean to his tutor?
|
|
|
|
|
No idea.
I gave him 25 hours to be kind, and then sent the email. He hasn't been back since...
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
|
haha
I like how he's told that they won't delete anything and he's like "Ok guys tnx at least delete this thread so she won't think I was doing anything wrong".
|
|
|
|
|
I just found this in some ancient C code:
if (number_of_records > 0)
{}
else
{}
I'd love to know what the original programmer was intending to do here because I have to maintain this crap!
|
|
|
|
|
He was just explaining syntax of if...else to his/her co-programmer. The co-programmer was free to cook anything between these {}.
|
|
|
|
|
There is the code I was looking for! Could you please tell me what file its in now
|
|
|
|
|
Yes, its in a function called read_the_mi_file() in MINSERT.C
If you'd like to take ownership of the whole pile of BS I'll ZIP it up for you..
|
|
|
|
|
It's a long standing game of Code Tennis.
You fill in the "if" part, and send it back for his move on the "else".
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
He had that variable number_of_records sitting around and had to do something with it.
|
|
|
|
|
Look at the bright side.
There's nothing to undo with this code.
|
|
|
|
|
The real question isn't what the original programmer was intending to do, but what do you need to do if number_of_records > 0 ?
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
OP may just have built this piece of code to prevent a warning saying that variable 'number_of_records' has been declared but is never used.
Quite brilliant, actually.
Women are composed of carbon, hydrogen, oxygen and nitrogen; men are also composed of carbon, hydrogen, oxygen and nitrogen, but in such proportions that force respect.
|
|
|
|
|
Looks like an incomplete sanity check. It should be:
if (number_of_records > 0)
{}
else if (number_of_records <= 0)
{}
else
{
printf("%d", *(int*)666);
}
Greetings - Jacek
|
|
|
|
|
It's always good to check whether a particular record is existing or not before accessing that record.
Specially in collections, sometimes it maybe empty or less than the number of required records that you want to access.
The following code will execute based on the records available
DataTable table = new System.Data.DataTable();
table.Columns.Add("ID");
table.Rows.Add("1");
string test = string.Empty;
int num_of_records = table.Rows.Count;
if (num_of_records > 0)
{
test = table.Rows[0][0].ToString();
}
else
{
return;
}
The following code is directly trying to access a record which may or may not be existing though the code is syntactically correct it may throw error in the event of unavailablity of records.
DataTable table = new System.Data.DataTable();
table.Columns.Add("ID");
string test = string.Empty;
test = table.Rows[0][0].ToString();
IndexOutOfRangeException - There is no row at position 0.
|
|
|
|