study c(vc中测试过)——基本变量,宏定义

来源:互联网 发布:string转json数组格式 编辑:程序博客网 时间:2024/05/30 05:42

#include "stdafx.h"
#include <stdio.h>

extern void main_fileoper22();
int main(int argv,char* arg[]){
 //命令行参数
 while(argv-->0){
  printf("%d=%s/n",argv,*arg++);
 }


 printf("start main....../n");
 main_fileoper22();


 return 0;
}

 

 

 

#include "stdafx.h"
#include <stdio.h>
#include <math.h>

/*数据类型长度,字符变量*/
int main_size()
{
 int a = 0;
 short b = 1;
 short int c = 2;
 int size = sizeof(a);
 int size2 = sizeof(b);
 printf("%d,%d/n",size,size2);

 
 char ch1 = getchar();
 putchar(ch1);

 scanf("%d",&a);
 printf("---%ld---",a);


 return 0;
}

 

 

#include "stdafx.h"
#include <stdio.h>
#include <math.h>

/*数据类型,输入输出*/
double globalvar;
int main_basicvar(){
 float a,b,c;
 double s,area;
 printf("%f,%f",a,globalvar);
 scanf("%f %f %f",&a,&b,&c);
 s = (a+b+c)/2.0;
 area = sqrt(s*(s-a)*(s-b)*(s-c));
 printf("%f",area);
 return 0;
}

 

#include "stdafx.h"
#include <math.h>

#define SQUARE x*x*x
#if !defined(SQUARE)
#define SQUARE x*x
#else
#define SQUARE x*x*x*x
#endif

#define ARRAY char*
typedef char* ARRAY2;

/*预处理:宏定义,类型定义,文件包含,条件编译*/
int main_define(){
 int x = 2;
 printf("start....../n");
 int a = 2*SQUARE;
 printf("%d/n",a);

 ARRAY array1,array2;
 array1 = "ssss";
 array2='d';
 ARRAY2 array11,array22;
 array11="wwww1";
 array22="wwww2";
 puts(array11);puts(array22);
 return 0;
}