#include
void chline(char, int, int);
int main()
{
int n, m;
char ch;
printf("Please enter an character:\n");
scanf_s("%c", &ch);
printf("Please enter two integers:\n");
scanf_s("%d%d", &n, &m);
chline(ch, n, m);
return 0;
}
void chline(char ch, int n, int m)
{
int i;
for (i = 1; i <= n; i++)
printf(" ");
for (; i<= m; i++)
printf("%c",ch);
printf("\n");
}
不知道你用的是哪個版本?我用vc2010運行沒有問題。
你試試這個:
scanf_s("%c", &ch,sizeof(ch));