一個(gè)代碼:
void display(uchar *p);
char h[4] = {'A','B','C','/0'};
char e[4] = {'E','F','L','/0'};
char l[4] = {'M','N','O','/0'};
char o[4] = {'X','Y','Z','/0'};
int main(void)
{
int i;
char c;
uint set[5];
set[0] = h;
set[1] = e;
set[2] = l;
set[3] = l;
set[4] = o;
while(1){
for (i = 0; i < 5; ++i){
display(set[i]);
printf("/n");
sleep(1);
}
}
}
void display(uchar *p)
{
while(*p != '/0'){
printf("%c", *p);
printf("%c", *(p+1));
++p;
}
}
test.c:21: 警告: 賦值時(shí)將指針賦給整數(shù),未作類型轉(zhuǎn)換
test.c:22: 警告: 賦值時(shí)將指針賦給整數(shù),未作類型轉(zhuǎn)換
test.c:23: 警告: 賦值時(shí)將指針賦給整數(shù),未作類型轉(zhuǎn)換
test.c:24: 警告: 賦值時(shí)將指針賦給整數(shù),未作類型轉(zhuǎn)換
test.c:25: 警告: 賦值時(shí)將指針賦給整數(shù),未作類型轉(zhuǎn)換
test.c:29: 警告: 傳遞參數(shù) 1 (屬于 ‘display')時(shí)將整數(shù)賦給指針,未作類型轉(zhuǎn)換
其中21-25就是
set[0] = h;
set[1] = e;
set[2] = l;
set[3] = l;
set[4] = o;
29是
display(set[i])
雖然只是警報(bào),并且在linux下面也可以運(yùn)行的很好.但是既然警告了.還是值得討論下.
待續(xù)~
關(guān)注中...
如果有哪位知道.可否回復(fù)告訴我.謝謝~
------------------------------------------------------------
關(guān)于這個(gè)問題,我問了寢室的小丁.經(jīng)過他的修改.程序已經(jīng)不報(bào)警告了.
void display(uchar *p);
char h[4] = {'A','B','C','/0'};
char e[4] = {'E','F','L','/0'};
char l[4] = {'M','N','O','/0'};
char o[4] = {'X','Y','Z','/0'};
int main(void)
{
int i;
char c;
int set[5];
set[0] =(int) h;
set[1] =(int) e;
set[2] =(int) l;
set[3] =(int) l;
set[4] =(int) o;
while(1){
for (i = 0; i < 5; ++i){
display((uchar *)set[i]);
printf("/n");
sleep(1);
}
}
}
void display(uchar *p)
{
while(*p != '/0'){
printf("%c", *p);
printf("%c", *(p+1));
++p;
}
}
新聞熱點(diǎn)
疑難解答
圖片精選