c - 传递 'draw_character' 的参数 4 使指针来自整数而不进行强制转换

标签 c

我不断收到警告:

在“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/

相关文章:

c - 获取 pid 试图用 C 停止程序

将多个 OpenCL 缓冲区组合成一个大缓冲区

c - 从C中的图像读取十六进制值

c - C 预处理器指令中的 double

c - O_APPEND 的使用

c++ - 如何使用dlang读取二进制文件数据

c - 主要不认识我的功能

c - 在 C 中,追加到打开的文件以供 Windows 控制台和 Linux 上的另一个程序读取

c - 链接列表创建 - 程序在接受输入后停止工作

c - C 中的段错误