[問題] 一樣的碼結果不一樣

作者: a75088285 (活在回憶中的回憶)   2019-03-11 16:26:28
開發平台(Platform): (Ex: Win10, Linux, ...)
VMware/fc8_fedora
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
gcc
問題(Question):
兩段程式碼對照相同但是卡在scanf出現記憶體區段錯誤
餵入的資料(Input):
#include <stdio.h>
int main()
{
int x,y,z,x1,y1,z1;
x=2;y=1,z=3;
x1=x;y1=y;z1=z;
x=z1;y=x1;z=z1+y1;
printf("%d %d %d\n",x1,y1,z1);
printf("%d %d %d\n",x,y,z);
return 0;
}
#include <stdio.h>
int main (void)
{
int a;//
作者: jerryh001   2019-03-11 16:31:00
scanf要&a
作者: CMJ0121 (請多指教!!)   2019-03-11 16:32:00
查 man : the next pointer must be a pointer to int
作者: IhateOGC (我討厭)   2019-03-11 16:37:00
作者: a75088285 (活在回憶中的回憶)   2019-03-11 17:05:00
感謝囧,東改西改結果是這個沒改…

Links booklink

Contact Us: admin [ a t ] ucptt.com