看板 Programming 關於我們 聯絡資訊
請教一下,以下的程式是在c語言課本上看到的 我在dev-c++內編譯,我的系統會給我這樣的回應: 11 C:\Documents and Settings\123test\桌面\1.c parse error before '{' token 13 C:\Documents and Settings\123test\桌面\1.c parse error before "for" 14 C:\Documents and Settings\123test\桌面\1.c parse error before numeric constan t 14 C:\Documents and Settings\123test\桌面\1.c conflicting types for `functiona' 4 C:\Documents and Settings\123test\桌面\1.c previous declaration of `functiona' 14 C:\Documents and Settings\123test\桌面\1.c [Warning] data definition has no type or storage class 16 C:\Documents and Settings\123test\桌面\1.c parse error before string constant 16 C:\Documents and Settings\123test\桌面\1.c [Warning] data definition has no type or storage class 21 C:\Documents and Settings\123test\桌面\1.c conflicting types for `functiona' 14 C:\Documents and Settings\123test\桌面\1.c previous declaration of `functiona' 我的程式碼如下 麻煩各位幫忙了 謝謝! #include<dos.h> #include<stdlib.h> #define SIZE 100 void functiona(int a[], int size); main() { int a[SIZE] = {0}; int i =0; for(i = 0; i <100; i++){a[i] = {1};} for(i = 0; i <100; i++){printf("%d",a[i]);} functiona(a , SIZE); //printf("\n%.2f",2.13); system("PAUSE"); } void functiona(int a[], int size) { int i,total = 0; for(i = 0; i < 100; i++) total += a[i]; system("PAUSE"); } -- ┌─────KKCITY─────┐KKMAN團隊 全新力作 ◎◎KKBOX◎◎ bbs.kkcity.com.tw 知名歌手通通都有 所有新歌想聽就聽 └──From:218.169.106.32 ──┘※※ 內容豐富多元的線上音樂台 ※※ --
march20:這本書應該很古老了, 很久(二十年XD?)以前 128.54.49.35 07/19 02:17
march20:c 還沒採那麼嚴的的 strong-typing policy 128.54.49.35 07/19 02:17
march20:function 沒給return type 也可以 compile 128.54.49.35 07/19 02:20
march20:main 前加個 int, 然後return 個 0 吧 128.54.49.35 07/19 02:20
march20:然後 a[i]={1} 是錯的 XD 128.54.49.35 07/19 02:20
march20:(沒過主要是a={1}, main 的 return type 128.54.49.35 07/19 02:23
march20:好像其實沒影響 XD) 128.54.49.35 07/19 02:24