在不同操作系统上输出程序的问题 [英] problem with output of the program on different OS
问题描述
我有一个我在Windows机器上创建的C程序。我编译了
并在Windows机器上执行了程序,每次运行它时它都会给我
一致的输出。例如。
输入a = 2,b = 3
假设要执行求和操作,然后:
输出:5
关于输入,输出始终一致且正确。
我尝试过在我的linux机器上运行程序。该程序编译
并执行,但我得到了奇怪的结果。例如。对于问题
以上加:
输入a = 2 b = 3
输出:1
i再次执行程序:
输入a = 2 b = 3
输出:6
又一次:
输入a = 2 b = 3
输出0
I have a C program which I created on Windows machine. I have compiled
and executed the program on windows machine and it gives me the
consistent output every time i run it. for eg.
input a = 2, b =3
lets say a sum operation is to be performed, then:
output: 5
The output is always consistent and correct with regards to input.
I tried to run the program on my linux machine. The program compiles
and executes but I''m getting strange results. For eg. for the problem
of addition above:
input a = 2 b = 3
output: 1
i execute the program again:
input a = 2 b = 3
output: 6
and again:
input a = 2 b= 3
output 0
What is happening ?
推荐答案
pereges说:
pereges said:
我有一个我在Windows机器上创建的C程序。 [...]
关于输入,输出始终一致且正确。
我试图在我的linux上运行程序机。该程序编译
并执行,但我得到了奇怪的结果。 [...]
发生了什么事?
I have a C program which I created on Windows machine. [...]
The output is always consistent and correct with regards to input.
I tried to run the program on my linux machine. The program compiles
and executes but I''m getting strange results. [...]
What is happening ?
未定义行为的典型案例。如需更详细的诊断,请
提供源代码。
-
Richard Heathfield< http:// www .cpax.org.uk>
电子邮件:-http:// www。 + rjh @
谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>
Usenet是一个奇怪的放置" - dmr 1999年7月29日
Classic case of undefined behaviour. For a more detailed diagnosis, please
provide source code.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
5月8日下午1:26,Richard Heathfield< r ... @ see.sig.invalidwrote:
< snip>
On May 8, 1:26 pm, Richard Heathfield <r...@see.sig.invalidwrote:
<snip>
未定义行为的经典案例。有关更详细的诊断,请
提供源代码。
Classic case of undefined behaviour. For a more detailed diagnosis, please
provide source code.
代码为650行,分为多个模块。我不介意
张贴它但是大多数人会怨恨它。
你认为使用非标准的问题会产生这样的问题吗? />
编译器如PellesC?
The code is 650 lines and it is divided in many modules. I don''t mind
posting it but most people will resent it.
Do yout think problems like this one can arise by using non standard
compilers like PellesC ?
pereges写道:
pereges wrote:
5月8日,1: 26 pm,Richard Heathfield< r ... @ see.sig.invalidwrote:
< snip>
On May 8, 1:26 pm, Richard Heathfield <r...@see.sig.invalidwrote:
<snip>
>未定义行为的经典案例。有关更详细的诊断,请
提供源代码。
>Classic case of undefined behaviour. For a more detailed diagnosis, please
provide source code.
代码为650行,分为多个模块。我不介意
张贴它但是大多数人会怨恨它。
你认为使用非标准的问题会产生这样的问题吗? />
编译器如PellesC?
The code is 650 lines and it is divided in many modules. I don''t mind
posting it but most people will resent it.
Do yout think problems like this one can arise by using non standard
compilers like PellesC ?
更可能是代码中的未定义行为依赖于原始编译器的
行为。
尝试并提炼一个证明问题的简短例子。
-
Ian Collins。
More likely undefined behaviour in the code that relies on the
behaviour of the original compiler.
Try and distill a short example that demonstrates the problem.
--
Ian Collins.
这篇关于在不同操作系统上输出程序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!