[英]C subscripted value is neither array nor pointer nor vector
你們可以在功能m上幫助我嗎? 這個想法是用printf的“標簽”,但我不明白這是怎么回事
#include <stdio.h>
#define MAXL 50
#define MAXC 50
unsigned int linhas;
unsigned int colunas;
int segC [MAXL];
int segL [MAXC];
char tab[MAXL][MAXC];
void c (){
int l,c,temp;
scanf("%d %d",&linhas,&colunas);
for (l=0;l<linhas;l++){
scanf("%d[^'']",&temp);
segC[l]=temp;
}
for (c=0;c<colunas;c++){
scanf("%d[^'']",&temp);
segC[c]=temp;
}
for(l=0;l<=linhas;l++){
for(c=0;c<colunas;c++){
scanf("%c",&tab[l][c]);
}
}
}
char m (linhas,colunas,segC,segL,tab){
int l,c;
int tempi;
char tempc;
for(l=0;l<=linhas;l++){
for(c=0;c<colunas;c++){
printf("%c",tab[l][c]);
}
tempi=segL[l];
printf("%d\n",tempi);
}
for(c=0;c<colunas;c++){
tempi=segC[c];
printf("%d",tempi);
}
printf("\n");
}
char h (int line){
}
int main (){
c();
//m(linhas,colunas,segC,segL,tab);
}
您缺少變量類型:
char m (linhas,colunas,segC,segL,tab)
像這樣重寫函數:
char m() {
/* ... */
}
您無需提供全局變量作為函數的參數; 實際上,局部函數參數遮蓋了全局變量。
最后,避免省略參數和變量類型; 從C99開始,至少是不推薦使用甚至是非法的(忽略的類型默認為int,這在這里引起了問題。)
更好的是,在main()中將它們聲明為局部變量,並通過偽引用將它們傳遞給m()
和c()
:
char m( unsigned int linhas, unsigned int colunas, int **segC, int **segL, char ***tab ) {
/* ... */
}
調用時傳遞segC,segL和tab的地址。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.