我不断收到警告:
在“main”函数中: 传递 'draw_character' 的参数 4 从整数生成指针而不进行强制转换 [注意] 应为 'char ** (*)[7]' 但参数类型为 'char'
但我不知道如何解决这些问题。我真的很感激你的回答:) 这是我的程序。
int draw_character(int ASCII_Value,int font,int height,char **output_matrix[7][7]);
void print_character(char **output_matrix);
int main(){
char **output_matrix[10][10];
int ASCII_Value = 0, height = 0;
printf("DRAW CHARACTER");
printf("\n\nEnter ASCII Value of the character : ");
scanf("%d", &ASCII_Value);
printf("FONT (1 - default or 2 - special): ");
scanf("%d", &font);
printf("Height: ");
scanf("%d", &height);
draw_character(ASCII_Value, font, height, **output_matrix[7][7]);
return 0;
}
int draw_character(int ASCII_Value,int font,int height,char **output_matrix[7][7]){
int rowsize;
if(font == 1)
{
height = 5;
rowsize = 6;
switch(ASCII_Value)
{
case 65:
case 97:
strncpy(**output_matrix[0]," * * ",6);
strncpy(**output_matrix[1]," * *",6);
strncpy(**output_matrix[2],"******",6);
strncpy(**output_matrix[3],"* *",6);
strncpy(**output_matrix[4],"* *",6);
print_character(**output_matrix);
break;
/*Print B*/
case 66:
case 98:
strncpy(**output_matrix[0],"******",6);
strncpy(**output_matrix[1],"* *",6);
strncpy(**output_matrix[2],"******",6);
strncpy(**output_matrix[3],"* *",6);
strncpy(**output_matrix[4],"******",6);
print_character(**output_matrix);
break;
/*Print C*/
case 67:
strncpy(**output_matrix[0]," *****",6);
strncpy(**output_matrix[1],"* ",6);
strncpy(**output_matrix[2],"* ",6);
strncpy(**output_matrix[3],"* ",6);
strncpy(**output_matrix[4]," *****",6);
print_character(**output_matrix);
break;
}
}
return 0;
}
void print_character(char **output_matrix){
printf(" %c", &output_matrix);
}
最佳答案
你正在解引用指向指针的指针
char **output_matrix[10][10];
draw_character(ASCII_Value, font, height, **output_matrix[7][7]);
相反,传递数组:
draw_character(ASCII_Value, font, height, output_matrix);
关于c - 传递 'draw_character' 的参数 4 使指针来自整数而不进行强制转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36372749/