printf撇号在C中用Æ代替

Mat*_*int 2 c windows string formatting

这是我的第一个comp sci赋值的一部分,我们正在编写一个C程序来评估几个方程.这是给出了不稳定结果的代码:

// 1. Newton’s Second Law of Motion
printf("Newton's Second Law of Motion \nPlease enter mass and acceleration as decimal-point values separated by a comma (ex. 150.0,5.5): ");
scanf("%lf, %lf", &mass, &accel);
printf("Newton’s Second Law of Motion: force = mass * acceleration = %lf * %lf = %lf\n\n\n", mass, accel, mass*accel);
Run Code Online (Sandbox Code Playgroud)

程序运行时,第一个printf显示正常,但第二个显示"牛顿"而不是"牛顿".

Luc*_*ore 8

你在使用UNICODE吗?

似乎撇号有区别:Newton’svs Newton's.你从某个地方复制粘贴了吗?

  • 啊,我必须有!修好了.非常感谢你! (2认同)

Mic*_*urr 5

值为0x92 的单字节字符将在不同系统上以不同方式显示,具体取决于当前有效的代码页.

代码页437(在美国很常见)显示Æ该值的字符.

其他代码页,如代码页1252(西欧),显示.