|·孩孒氣ジ 发表于 2015-2-23 23:15:52

求助 为什么出那么多的错误

#include <stdio.h>
void printfchars(int x,int y)
int a={1,2,3,4,5,6,7,8,9,10,11,12};
    int b,c,z;
    int *p;

void main()
{
       
        printf("i=");
        scanf("%d",&b);
        if(b<0||b>2)
        {
      printf("i=");
          scanf("%d",&b);
        }
    printf("j=");
        scanf("%d",&c);
        if(c<0||c>3)
        {
      printf("j=");
          scanf("%d",&c);
        }
        printf("a[%d][%d]=%d",b,c,printfchars(b,c));
}

void printfchars(int x,int y)
{
        *p=a;
    z=*(*p);
        return z;
}

|·孩孒氣ジ 发表于 2015-2-23 23:18:40

Compiling...
z.c
C:\Users\Yourflower\Documents\z.c(3) : error C2085: 'a' : not in formal parameter list
C:\Users\Yourflower\Documents\z.c(3) : error C2143: syntax error : missing ';' before '='
C:\Users\Yourflower\Documents\z.c(24) : error C2095: 'printf' : actual parameter has type 'void' : parameter 4
C:\Users\Yourflower\Documents\z.c(28) : error C2084: function 'void __cdecl printfchars(int ,int )' already has a body
C:\Users\Yourflower\Documents\z.c(29) : error C2065: 'a' : undeclared identifier
C:\Users\Yourflower\Documents\z.c(30) : error C2109: subscript requires array or pointer type
C:\Users\Yourflower\Documents\z.c(30) : error C2100: illegal indirection
C:\Users\Yourflower\Documents\z.c(30) : error C2100: illegal indirection
C:\Users\Yourflower\Documents\z.c(31) : warning C4098: 'printfchars' : 'void' function returning a value
执行 cl.exe 时出错.

牡丹花下死做鬼 发表于 2015-2-24 00:03:52

(⊙o⊙)…
首先函数应该是 int printfchars(int x,int y); 的吧 你分号没了
其次
二维数组可不是那么简单的
*p = a;(⊙o⊙)… 我怀疑你一维数组都不会吧

wjx777 发表于 2015-2-24 22:22:26

页: [1]
查看完整版本: 求助 为什么出那么多的错误