0
我想的雙維數組到現在,如果這是聲明字符串C中的數組,像這樣一個正確的方法:聲明字符串
#include <stdio.h>
#include <string.h>
#define rows 6
#define colu 2
char* bdato [rows][colu]={/*here using the pointer, I'm not sure*/
{"tc","Torta Cubana "},
{"th","Torta Huatulco"},
{"tm","Torta Mexicana"},
{"tr","Torta Rusa "},
{"r ","Refresco "},
{"a ","Agua sabor "}};
int impri(){
int x;
for (x=0;x<6;x+=1) {
printf("%s %s \n",bdato[x][0],bdato[x][1]);
}
return 0;
}
是的。還要別的嗎? – Axalo
我在網上看,看到這樣的東西不是一個正確的方式來聲明它,因爲我沒有讀取數據只有方向,它使用malloc更好,但我學習,所以我不知道。這是我第一週學習編程 – user2461687
這取決於你想要做什麼。它與一維數組基本相同。見[這裏](http://stackoverflow.com/questions/11241014/malloc-or-normal-array-definition)和[這裏](http://stackoverflow.com/questions/3269627/c-local-array-定義抗α-malloc的呼叫?RQ = 1)。 – Axalo