Results 1 to 2 of 2
Try creating a C function like
Code:
int x = 789;
void myfunc()
{
return x;
}
Now try calling this function in your code:
first try:
myfunc();
then try:
...
- 11-28-2008 #1
C function oddity
Try creating a C function like
Now try calling this function in your code:Code:int x = 789; void myfunc() { return x; }
first try:
myfunc();
then try:
myfunc(3456);
and then:
myfunc(3456, "this is some text");
You will find the function will work correctly, that is it will ignore the values pasted to the function...
To correct this define the function as:
Just one of the odd things I discovered in C...Gerard4143Code:int x = 789; void myfunc(void) { return x; }
- 11-28-2008 #2
You mean the second code snippet will return a double passed to it, despite "x" being defined as a global outside of the function ?
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode


Reply With Quote