#include
int BLURB = 200;
int rv;
int main(void)
{
rv = printf("%d\n",BLURB);
printf("the %d\n",rv);
return 0;
}
%d ,rv
rv 的值是多少 ?
以及为什么
Parameters
format
Format control.
argument
Optional arguments.
Return Values
Each function returns the number of characters printed, or a negative value if an error occurs.
rv的值是4,printf返回的是打印的字符数
char *change(char a[]){
int c,i;
char b[1000];
c=strlen(a)-1;
b[c+1]='\0';
for(i=0;c>=0;c--,i++)
b[i]=a[c];
strcpy(a,b);
return a;
}
你的b未赋值前应该将末尾字符设为‘\0’
****printf返回表示被打印的字符数*****
#include <stdio.h>
int BLURB = 200;
int rv;
char b = 100; //b位字符d
int main(void)
{
rv = printf("%d\n", BLURB);
printf("%d\n", rv); //rv == 2 0 0+'\n' 字符数4 打印4
rv = printf("%c", b);
printf("%d", rv); //rv == 字符‘d’ 字符数1 打印1
return 0;
}