看板Programming
标 题参考书本范例,却错误一堆的C语言范例..
发信站KKCITY (Thu Jul 19 00:01:21 2007)
转信站ptt!ctu-reader!ctu-gate!news.nctu!news.ntu!news.au!zoonews.ee.ntu!news
请教一下,以下的程式是在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
》──┘※※ 内容丰富多元的线上音乐台 ※※
--
1F:推 march20:这本书应该很古老了, 很久(二十年XD?)以前 128.54.49.35 07/19 02:17
2F:推 march20:c 还没采那麽严的的 strong-typing policy 128.54.49.35 07/19 02:17
3F:推 march20:function 没给return type 也可以 compile 128.54.49.35 07/19 02:20
4F:推 march20:main 前加个 int, 然後return 个 0 吧 128.54.49.35 07/19 02:20
5F:推 march20:然後 a[i]={1} 是错的 XD 128.54.49.35 07/19 02:20
6F:推 march20:(没过主要是a={1}, main 的 return type 128.54.49.35 07/19 02:23
7F:推 march20:好像其实没影响 XD) 128.54.49.35 07/19 02:24