Home > OS >  Linux application calls dynamic library function, the parameter values
Linux application calls dynamic library function, the parameter values

Time:09-16

A process called a dynamic library function, to participate in, after calculation, ginseng, value is not the expected data
For example,
Func (a, b, c)
{
c=a+b;
}
The main ()
{
Int I=1, j=2 and k=0;
Func (I, j, k);
Printf (" k=% d \ n ", k);
}
K value is invalid as a result, in the other process calls the function is normal, the aunt, discuss under what circumstances can lead to this situation?

CodePudding user response:

Fill section C language function, parameter will not change the argument, the return value, if want to use parameters using a pointer,
Func (int a, b int, int * c)
{
* c=a + b;
}

CodePudding user response:

This is my a slip of the pen, is the original pointer type, strange calls are no problem in other processes

CodePudding user response:

reference 1st floor acuity_ response:
fill section C language function, parameter will not change the argument, if you want to use the return value parameters, using a pointer,
Func (int a, b int, int * c)
{
* c=a + b;
}


And there is no problem, I print in the library function results out value is wrong
  • Related