空暇时的思考1(二维数组存储字符串和指针)

 事实上每次看到关于字符串的操作我都十分的好奇。就想一探到底。下面是自己闲来无事思考自己娱乐的一个程序

/**********************************************************************     
* *   Copyright (c)2015,WK Studios   
* *   Filename:  A.h 
* *   Compiler: GCC  vc 6.0    
* *   Author:WK     
* *   Time: 2015 29 6  
* **********************************************************************/ 
#include <iostream>
using namespace std;

void main()
{
	char a[2][6]={"12345","abcde"};

  cout<<a[0]<<endl;
  cout<<a[1]<<endl;
  cout<<a[0]+1<<endl;

  cout<<*(a+1)<<endl;
  cout<<*(*(a+1))<<endl;

  cout<<*a<<endl;
  cout<<**a<<endl;
  cout<<a[0][0]<<endl;
  cout<<a[0][0]+1<<endl;

  char (*p)[6]=a;
  cout<<p[1]<<endl;
  cout<<*p<<endl;
  cout<<**p<<endl;
  cout<<p<<endl;
  cout<<*p+1<<endl;
  cout<<**p+1<<endl;

  char (&q)[2][6]=a;
  cout<<q<<endl;
 
}


void fun(int i=0,int=0,float n=0)//占位符能够实现代码的可扩展性,是一种面向未来的编程
{
	cout<<i+n<<endl;
}

void main()
{
	fun(1,0,0.5);

	fun(1,0);//最后这个零会赋给这个占位符,后边的參数使用缺省值

  
}


posted on 2016-02-23 16:06  gcczhongduan  阅读(236)  评论(0编辑  收藏  举报