随笔 - 505  文章 - 1034  trackbacks - 0
<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678


子曾经曰过:编程无他,唯手熟尔!

常用链接

留言簿(94)

随笔分类(649)

随笔档案(505)

相册

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

积分与排名

  • 积分 - 894811
  • 排名 - 14

最新随笔

最新评论

阅读排行榜

评论排行榜

这么基础的居然不清楚!

// 01_strcpy.cpp : 定义控制台应用程序的入口点。
//

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

char* my_strcpy(char* strDest, const char* strSrc)
{
    assert(strDest 
!= NULL && strSrc != NULL);
    
char* address = strDest;
    
while ( (*strDest++ = *strSrc++!= '\0' )
        NULL;
    
return address;
}

int _tmain(int argc, _TCHAR* argv[])
{
    
char strDest[32= {0};
    my_strcpy(strDest, 
"Hello World");
    printf(
"%s\n", strDest);

    
const char* p = "Hello"// p指向的内存单元不可修改
    p++;
    printf(
"%c\n", p[0]); // e
    
// p[0] = 'a'; // error C3892: “p”: 不能给常量赋值

    
char* const q = "world"// q指针本身为常量。
    
// q++; // error C3892: “q”: 不能给常量赋值

    
const char* const r = "rrr"// r指向的内存单元不可修改,r指针本身为常量;
    
    
int value = 4;
    value 
= 5;

    
const int iVal = 3;
    
//iVal = 2; // error C3892: “iVal”: 不能给常量赋值

    
return 0;
}

posted on 2011-02-16 17:01 七星重剑 阅读(1954) 评论(0)  编辑 收藏 引用 所属分类: PL--c/c++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理