例如有一種方法狗通過一個字符值:C編程:如何打印作爲一個參數
void dog(char C,int N)
{
//here if I want to print the value of C with a print statement,how do I do that?
}
例如有一種方法狗通過一個字符值:C編程:如何打印作爲一個參數
void dog(char C,int N)
{
//here if I want to print the value of C with a print statement,how do I do that?
}
有你可以做到這一點的幾種方法。
可以說存儲在char c
中的值是字母「H」。
最基本的方法將要求您使用putchar
,如果你只希望看到的值:
putchar(c);
putchar
會給你的C只值和一個換行符。
因此,這將打印出:
H
不過,如果你想與其他文本在同一行中的值,你可以使用printf
:
printf("The value stored in C is: %c\n", C);
這將打印出:
The value stored in C is: H
printf
可讓您用文本行添加值,但不存在換行符,所以您必須自己添加一個,就像我一樣。
希望能夠澄清一點點。
做這個
void dog(char C,int N)
{
fprintf(stdout, "C = %c N = %d\n", C, N);
}
爲什麼你想要的參數'INT N'。 – Stan
@Stan也許'C'應該打印'N'次?這是我的猜測... –
@ChronoKitsune所以op應該更清楚地描述這個問題:) – Stan