Chinaunix首页 | 论坛 | 博客

OS

  • 博客访问: 2219367
  • 博文数量: 691
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2660
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-05 12:49
个人简介

不浮躁

文章分类

全部博文(691)

文章存档

2019年(1)

2017年(12)

2016年(99)

2015年(207)

2014年(372)

分类: C/C++

2016-03-12 12:02:25

1.hello world
  helloworld.c
 
#include "print.h"

int main(void){
 printHello();
 return 0;
}

print.c
#include "print.h"

void printHello()
{
 printf("hello word!\n");
}

print.h
#include "stdio.h"

void printHello(void);

gcc helloword.c print.c  print.h -o helloword
./helloword
hello word!


2.打印字符串
/* */
#include
main()
{
 char ch,nch; /* */
 int count; /* */
 int k;  /* */

 printf("Please input a string with a # in the end.\n");
 scanf("%c",&ch); /* */
 while(ch != '#') /* */
 {
  if(ch >= '0' && ch <= '9')
  {
   /* */
   count = ch-'0'+1; /* */
   scanf("%c",&nch); /* */
   for(k=0;k   }
  else
   printf("%c",ch); /* */
  printf(" ");   /* */
  scanf("%c",&ch);  /* */
 }
 printf("#\n");    /* */
}
  
#include
main()
{
 int a=5,b,c,i=10;
 b=a++;
 c=++b;

 printf("a = %d, b = %d, c = %d\n",a,b,c);
 printf("i,i++,i++ = %d,%d,%d\n",i,i++,i++);
 printf("%d\n",++i);
 printf("%d\n",--i);
 printf("%d\n",i++);
 printf("%d\n",i--);
 printf("%d\n",-i++);
 printf("%d\n",-i--);
 getchar();
}

./7
a = 6, b = 6, c = 6
i,i++,i++ = 12,11,10
13
12
12
13
-12
-13
c

             

阅读(1215) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~