|
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.
|
|
|
|
|
I agree, and the original post was probably more of a question of what the developer intended to do inside the {} in both the if part and the else part; which of course could be anything.
If anything it's just dead code the compiler would likely cut out.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
From the legacy VB6 app being ported...
Private Sub cmdGateway_Click()
If UCase("" & InputBox("Input password")) <> "DIFFERENT" Then
MsgBox ("Incorrect password")
Exit Sub
Else
MsgBox ("Password accepted")
End If
End Sub
The real password was not as above, but in every other sense this is representative.
The same password is used for many "sensitive" commands through the app. In this case though, the button simply checks the password and does nothing else.
I'm off for some mind bleach (whiskey).
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
The original 'Script Kiddie' (Programmer is too professional a term for this guy) obviously didn't know anything about security.
Getting information off the Internet is like taking a drink from a fire hydrant.
- Mitchell Kapor
|
|
|
|
|
Well, he knew that he needed a password for something, just not for what thing
|
|
|
|
|
Whats the problem? It's completely secure provided you ship a copy of VS and the source to each user so they can set their own...
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|