#include <stdio.h>
void main()
{
int a=5,b=7;
float x=67.8564,y=-789.124;
char c=‘a’;
long n=1234567;
unsigned u=65536;
printf(“%d%d\n”,a,b);
printf(“%3d%3d\n”,a,b);
printf(“%f,%f\n”,x,y);
printf(“%-10f,%-10f\n”,x,y);
printf(“%8.2f,%8.2f,%.4f,%.4f,%3f,%3f\n”,x,y,x,y,x,y);
printf(“%c,%d,%o,%x\n”,c,c,c,c);
printf(“%ld,%lo,%x\n”,n,n,n);
printf(“%u,%o,%x,%d\n”,u,u,u,u);
printf(“%s,%5.3s\n”,”computer”,”computer”);
}
双引号 和 单引号 都是中文模式的,改成英文模式
#include <stdio.h>
void main()
{
int a=5,b=7;
float x=67.8564,y=-789.124;
char c='a';
long n=1234567;
unsigned u=65536;
printf("%d%d\n",a,b);
printf("%3d%3d\n",a,b);
printf("%f,%f\n",x,y);
printf("%-10f,%-10f\n",x,y);
printf("%8.2f,%8.2f,%.4f,%.4f,%3f,%3f\n",x,y,x,y,x,y);
printf("%c,%d,%o,%x\n",c,c,c,c);
printf("%ld,%lo,%x\n",n,n,n);
printf("%u,%o,%x,%d\n",u,u,u,u);
printf("%s,%5.3s\n","computer","computer");
}
char c=‘a’;
这里引号是中文全角的
char c='a';
printf(“%d%d\n”,a,b);
包括以下,这些引号都是全角的
printf("%d%d\n",a,b);
#include <stdio.h>
void main()
{
int a=5,b=7;
float x=67.8564,y=-789.124;
char c='a';
long n=1234567;
unsigned u=65536;
printf("%d%d\n",a,b);
printf("%3d%3d\n",a,b);
printf("%f,%f\n",x,y);
printf("%-10f,%-10f\n",x,y);
printf("%8.2f,%8.2f,%.4f,%.4f,%3f,%3f\n",x,y,x,y,x,y);
printf("%c,%d,%o,%x\n",c,c,c,c);
printf("%ld,%lo,%x\n",n,n,n);
printf("%u,%o,%x,%d\n",u,u,u,u);
printf("%s,%5.3s\n","computer","computer");
}
不知道你这个问题是否已经解决, 如果还没有解决的话:例如如下代码就是在c++中包含c语言的头文件的正确方式。
//c++是可以和c混合编辑的 但是c语言的头文件必须用extern 括起来,不括起来可能有时会出错
extern "C" {
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
}