这是我的代码 我用的是VC6 编译不了 但是我删掉这句"display(ch,rows,cols);" 就能编译了 求大神解答

如题所述

我vc6和dev-cpp都可以编译啊。。你的报错是啥啊?

另外,你的代码应该有一些错误,我改过了之后是这样的(输入:字符+空格+行数+空格+列数)

#include <stdio.h>
void display(char cr,int lines,int width);
int main(void){
    char ch;
    int rows,cols;
    printf("Enter a character and two integers:\n");
    while((ch=getchar())&&(getchar()!='\n')){
        scanf("%d %d",&rows,&cols);
        display(ch,rows,cols);
        printf("Enter another character and two integers:\n");
        printf("Enter a newline to quit.\n");
    }
    printf("Bye.\n");
    return 0;
}
void display(char cr,int lines,int width){
    int row,col;
    for(row=1;row<=lines;row++){
        for(col=1;col<=width;col++){
            putchar(cr);
        }
        putchar('\n');
    }
}

温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜