[問題] 函數回傳值不正確
開發平台(Platform): (Ex: VC++, Gcc, Linux, ...)
DEV C++
額外使用到的庫(Library Used) (Ex: OpenGL, ...)
問題(Question):
不管怎麼寫我的函數 回傳的值都不正確
像下面這個相加的函數
預期回傳3+4=7
可是程式跑出來卻是16384
我的程式問題到底在哪呢?
程式碼(Code): (請善用置底文標色功能)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int add(int a,int b)
{
int c;
c==a+b;
return (c);
}
main()
{
int x,y;
x==3;
y==4;
printf("%d",add(x,y));
system("PAUSE");
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.101.199
→
01/06 21:04, , 1F
01/06 21:04, 1F
推
01/06 21:07, , 2F
01/06 21:07, 2F
→
01/06 21:07, , 3F
01/06 21:07, 3F
→
01/06 21:12, , 4F
01/06 21:12, 4F
→
01/06 21:12, , 5F
01/06 21:12, 5F
推
01/06 21:28, , 6F
01/06 21:28, 6F
→
01/07 07:28, , 7F
01/07 07:28, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章
11
38