C
confusedcoder
I found a strange piece of code that basically did the following:
int doSomething(int& foo)
{
//manipulate the value of foo
return foo;
}
int main(int argc, char* argv[])
{
int a = 5;
a = doSomething(a);
return 0;
}
Aside from being very bad practice, what problems does this present? I
am asking because it was causing the program to crash on a small number
of computers that it was running on. I have changed the code so that
it doesn't crash anymore, but I am curious as to what the problem may
have been.
int doSomething(int& foo)
{
//manipulate the value of foo
return foo;
}
int main(int argc, char* argv[])
{
int a = 5;
a = doSomething(a);
return 0;
}
Aside from being very bad practice, what problems does this present? I
am asking because it was causing the program to crash on a small number
of computers that it was running on. I have changed the code so that
it doesn't crash anymore, but I am curious as to what the problem may
have been.