我知道下面的程序几乎是错误的,我正在寻找一个 hep 来解决这个问题,请帮助:
#include <stdio.h>
#include <string.h>
int i;
float r;
char c;
char s[48];
int main() {
i=4;
r=3;
c='z';
strcpy(s,"Hi There");
printf("i=%d,r=%d,c=%d")
}
我知道下面的程序几乎是错误的,我正在寻找一个 hep 来解决这个问题,请帮助:
#include <stdio.h>
#include <string.h>
int i;
float r;
char c;
char s[48];
int main() {
i=4;
r=3;
c='z';
strcpy(s,"Hi There");
printf("i=%d,r=%d,c=%d")
}
首先,当你说某事是错的时,指出错在哪里可能会有所帮助。例如,添加预期的和实际的输出,或者在编译或链接时遇到的错误。
其次,错误可能是printf
调用打印了奇怪的值。这是因为您告诉它打印三个值,但您实际上并没有提供要打印的值。改成
printf("i=%d,r=%d,c=%d", i, r, c);
#include <stdio.h>
#include <string.h>
int main(){
int i;
float r;
char c;
char s[48];
i=4;
r=3.0;
c='z';
strcpy(s,"Hi There");
printf("i=%d, r=%hf, c=\'%c\', s=\"%s\"", i, r, c, s);
return 0;
}