typedef struct
{
int a[6];
int b;
}object;
object t1,t2,t3,t4;
当我调用math.h中的pow(float x,float y)函数来进行指数计算的时候发现t3和t4中的值被改的面目全非,参数x和y只是两个常数,不和t3、t4发生关系,而pow()函数也返回了正确的结果。
因为使用的单片机只有64K内存,定义的变量也很多,减少定义的变量后t3正常了,t4的值依旧会被改变。因此怀疑是在执行pow()函数的时候占用过大内存导致的。
想请教一下各位大侠,C语言中是否可以指定某个变量不被更改呢,只能在代码中修改。
2 个解决方案
#1
pow
Calculates x raised to the power of y.
double pow( double x, double y );
Routine Required Header Compatibility
pow <math.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
pow returns the value of xy. No error message is printed on overflow or underflow.
Values of x and y Return Value of pow
x < > 0 and y = 0.0 1
x = 0.0 and y = 0.0 1
x = 0.0 and y < 0 INF
Parameters
x
Base
y
Exponent
Remarks
The pow function computes x raised to the power of y.
pow does not recognize integral floating-point values greater than 264, such as 1.0E100.
Example
/* POW.C
*
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double x = 2.0, y = 3.0, z;
z = pow( x, y );
printf( "%.1f to the power of %.1f is %.1f\n", x, y, z );
}
Output
2.0 to the power of 3.0 is 8.0
Floating-Point Support Routines
See Also exp, log, sqrt
Calculates x raised to the power of y.
double pow( double x, double y );
Routine Required Header Compatibility
pow <math.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
pow returns the value of xy. No error message is printed on overflow or underflow.
Values of x and y Return Value of pow
x < > 0 and y = 0.0 1
x = 0.0 and y = 0.0 1
x = 0.0 and y < 0 INF
Parameters
x
Base
y
Exponent
Remarks
The pow function computes x raised to the power of y.
pow does not recognize integral floating-point values greater than 264, such as 1.0E100.
Example
/* POW.C
*
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double x = 2.0, y = 3.0, z;
z = pow( x, y );
printf( "%.1f to the power of %.1f is %.1f\n", x, y, z );
}
Output
2.0 to the power of 3.0 is 8.0
Floating-Point Support Routines
See Also exp, log, sqrt
#2
To set a breakpoint when a variable changes value
From the Edit menu, click Breakpoints.
Click the Data tab of the Breakpoints dialog box.
In the Expression text box, type the name of the variable.
Click OK to set the breakpoint.
From the Edit menu, click Breakpoints.
Click the Data tab of the Breakpoints dialog box.
In the Expression text box, type the name of the variable.
Click OK to set the breakpoint.
#1
pow
Calculates x raised to the power of y.
double pow( double x, double y );
Routine Required Header Compatibility
pow <math.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
pow returns the value of xy. No error message is printed on overflow or underflow.
Values of x and y Return Value of pow
x < > 0 and y = 0.0 1
x = 0.0 and y = 0.0 1
x = 0.0 and y < 0 INF
Parameters
x
Base
y
Exponent
Remarks
The pow function computes x raised to the power of y.
pow does not recognize integral floating-point values greater than 264, such as 1.0E100.
Example
/* POW.C
*
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double x = 2.0, y = 3.0, z;
z = pow( x, y );
printf( "%.1f to the power of %.1f is %.1f\n", x, y, z );
}
Output
2.0 to the power of 3.0 is 8.0
Floating-Point Support Routines
See Also exp, log, sqrt
Calculates x raised to the power of y.
double pow( double x, double y );
Routine Required Header Compatibility
pow <math.h> ANSI, Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
pow returns the value of xy. No error message is printed on overflow or underflow.
Values of x and y Return Value of pow
x < > 0 and y = 0.0 1
x = 0.0 and y = 0.0 1
x = 0.0 and y < 0 INF
Parameters
x
Base
y
Exponent
Remarks
The pow function computes x raised to the power of y.
pow does not recognize integral floating-point values greater than 264, such as 1.0E100.
Example
/* POW.C
*
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double x = 2.0, y = 3.0, z;
z = pow( x, y );
printf( "%.1f to the power of %.1f is %.1f\n", x, y, z );
}
Output
2.0 to the power of 3.0 is 8.0
Floating-Point Support Routines
See Also exp, log, sqrt
#2
To set a breakpoint when a variable changes value
From the Edit menu, click Breakpoints.
Click the Data tab of the Breakpoints dialog box.
In the Expression text box, type the name of the variable.
Click OK to set the breakpoint.
From the Edit menu, click Breakpoints.
Click the Data tab of the Breakpoints dialog box.
In the Expression text box, type the name of the variable.
Click OK to set the breakpoint.