user-0 提问: 求指教！为什么这个程序vc可以输出结果在Dev-cpp运行到scanf那里就不走了

回复:
user: user-1
content: 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 http://bbs.csdn.net/topics/390676437

user: user-0
content: 引用 13 楼 brookmill 的回复:我觉得可能是unsigned int和%d不匹配造成的问题。楼主可以试试这两个改动： 1. unsigned int a=0; scanf("%u",&a); 2. int a=0; scanf("%d",&a); 一般情况下unsigned int和%d混用都问题不大，dev-cpp不知道有什么不一样。  顺便说一句，我刚入行的时候曾经这么干过： short a; scanf("%d", &a); 结果就把栈弄崩了，自己还不知道是怎么回事。从那以后就觉得scanf太危险了（其实该说指针太危险了）  非常感谢 不过我试过了不是这个原因 原因是就是上面所说的 还是很感谢

user: user-0
content: 引用 14 楼 zhao4zhong1 的回复: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 http://bbs.csdn.net/topics/390676437    非常感谢！！ 我看了Dev有关math.h里面有关pow的定义发现pow的参数必须是float 或者 long double型 如下： /* 7.12.7.4 The pow functions. Double in C89 */ extern float __cdecl powf (float, float); #ifndef __NO_INLINE__ __CRT_INLINE float __cdecl powf (float x, float y)   {return (float) pow (x, y);} #endif extern long double __cdecl powl (long double, long double); 改过来就好了

user: user-2
content: 我觉得可能是unsigned int和%d不匹配造成的问题。楼主可以试试这两个改动： 1. unsigned int a=0; scanf("%u",&a); 2. int a=0; scanf("%d",&a); 一般情况下unsigned int和%d混用都问题不大，dev-cpp不知道有什么不一样。  顺便说一句，我刚入行的时候曾经这么干过： short a; scanf("%d", &a); 结果就把栈弄崩了，自己还不知道是怎么回事。从那以后就觉得scanf太危险了（其实该说指针太危险了）

user: user-3
content: gcc下执行的确没问题 我的C-Free执行的确出不来结果，我单步时发现n在i等于2时变成了99而不是100，不知道是不是编译器问题—— 楼主不妨单步一下VC6和dev试试，看看有什么不同

user: user-0
content: 引用 10 楼 T5500 的回复:汗，没看仔细你的问题，帮不上忙了 还是很感谢！

user: user-4
content: 汗，没看仔细你的问题，帮不上忙了

user: user-0
content: 好吧。。。 我去看看Dev和其他编译器有什么不同

user: user-4
content: gcc 4.9.0

user: user-0
content: 引用 5 楼 T5500 的回复: 执行没问题啊 哦？兄弟你用的也是Dev吗？

user: user-0
content: [img=https://img-bbs.csdn.net/upload/201408/13/1407938524_155258.png][/img 在vc里就是这样可以出来 在Dev里就蛋疼了。。。。 不知道怎么弄了

user: user-4
content: 执行没问题啊

user: user-5
content: 是不是死循环了？？

user: user-0
content: 走到这就不走了

user: user-4
content: 正在等你输入一个正整数