[問題] 請問一題課本code範例
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Ubuntu 10.04
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
我想應該是型態 int 與 int * 型態不同, 也可能是編譯器版本與課本不同
請問版上大大該如何改code 或是 調整其她部份
謝謝 <(_ _)>~~
餵入的資料(Input):
gcc pnt_add.c
預期的正確結果(Expected Output):
pointers + 0: 56014 56026
pointers + 1: 56016 56030
pointers + 2: 56018 56034
pointers + 3: 56020 56038
錯誤結果(Wrong Output):
pnt_add.c: In function ‘main’:
pnt_add.c:12: warning: format ‘%10u’ expects type ‘int’, but argument 3 has
type ‘int *’
pnt_add.c:12: warning: format ‘%10u’ expects type ‘int’, but argument 4 has
type ‘float *’
程式碼(Code):(請善用置底文網頁, 記得排版)
// pnt_add.c -- pointer addition
#include<stdio.h>
#define SIZE 4
int main(void)
{
int dates[SIZE], *pti , index;
float bills[SIZE], *ptf;
pti = dates;
ptf = bills;
for ( index = 0; index < SIZE; index ++ )
printf( "pointers + %d: %10u %10u\n", index, pti + index, ptf + index );
return 0;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.174.118.46
→
08/03 15:15, , 1F
08/03 15:15, 1F
→
08/03 15:16, , 2F
08/03 15:16, 2F
→
08/03 15:16, , 3F
08/03 15:16, 3F
→
08/03 16:07, , 4F
08/03 16:07, 4F
→
08/03 16:08, , 5F
08/03 16:08, 5F
推
08/03 16:47, , 6F
08/03 16:47, 6F
→
08/03 18:28, , 7F
08/03 18:28, 7F
推
08/03 19:25, , 8F
08/03 19:25, 8F
→
08/03 20:16, , 9F
08/03 20:16, 9F
→
08/03 20:21, , 10F
08/03 20:21, 10F
推
08/03 20:43, , 11F
08/03 20:43, 11F
→
08/03 21:41, , 12F
08/03 21:41, 12F
→
08/03 21:42, , 13F
08/03 21:42, 13F
→
08/03 21:42, , 14F
08/03 21:42, 14F
→
08/03 21:49, , 15F
08/03 21:49, 15F
→
08/03 21:55, , 16F
08/03 21:55, 16F
→
08/03 21:56, , 17F
08/03 21:56, 17F
→
08/03 21:57, , 18F
08/03 21:57, 18F
推
08/03 23:18, , 19F
08/03 23:18, 19F
→
08/04 00:11, , 20F
08/04 00:11, 20F
推
08/04 00:17, , 21F
08/04 00:17, 21F
→
08/05 13:50, , 22F
08/05 13:50, 22F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章