易截截图软件、单文件、免安装、纯绿色、仅160KB

c/c++ string


1.本章思维导图:



Example1:
char
*strcpy(char *target, const char *source) {
  char *t = target;

  // Copy the contents of source into target.
 
while(*source) *target++ = *source++;
  // Null-terminate the
target.
  *target = '\0';
  // Return pointer to the
start of target.
  return t;
}
Example2:
void
*memmove(void *target, const void *source, size_t count)
这个函数即使
是在源和目的字符串有所重叠时操作也能成功,虽然source为const,但是其指向的array也可能被修改。
2.
C型字符串操作实例:
Ex1.基本操作
/*
*

=====================================================================================

*
*       Filename:  2-1.cpp
*
*   
Description:  Fundamental Operations in C Type String
*
*       
Version:  1.0
*        Created:  05/11/2010 10:43:11 AM
*      
Revision:  none
*       Compiler:  gcc
*
*        
Author:  gnuhpc (http://blog.csdn.net/gnuhpc)
,
warmbupt@gmail.com
*        Company:  IBM CDL
*
*

=====================================================================================

*/
#include 
#include 
using namespace std;
int main(int argc, char *argv[])
{

    char strA[7]="UP";
    char strB[5]="DOWN";
   
char strC[5]="LEFT";
    char strD[6]="RIGHT";
   
/*Display */
    cout << "Here are the strings: " <<
endl;


相关文档:

交换连个对象的值(C/C++?JAVA)

如何交换两个变量的值:
C语言中的传值代码如下:
int change(int x,int y)
{
int temp=x;
x=y;
y=temp;
}
C语言中的传址代码如下:
int change(int *p,int *q)
{
int temp=*p;
*p=*q;
*q=temp;
}
使用C++中的引用类型代码如下:
int change(int &x,int &y)
{
int temp=x;
x=y;
y=temp;
}
JAV ......

c/c++头文件,保存,备用

 
C、传统 C++
#include <stdio.h>     //定义输入/输出函数
#include <stdlib.h>    //定义杂项函数及内存分配函数
#include <string.h>    //字符串处理
#include <assert.h>    //设定插入点
#include <ctype.h>     //字符处理
#include <errno.h&g ......

C和C++的点滴积累(1)

                     C和C++的点滴积累(1)
1. mfc 编程中存在着如果出现“内存不足”的对话框,一种情况是在申请内存的时候出现问题,也就是例如:char *pChar = new char[num]; 但此时num 为零或者负 ......

Delphi调用VC++6.0编写的Dll

用VC++6.0编写了一个简单的dll,里面包含一个减法函数subtract(int a,int b),Dll命名为ff.Dll
代码如下:
1.ff.cpp:
// ff.cpp : Defines the entry point for the DLL application.
//
#include "StdAfx.h"
#include "ff.h"
BOOL APIENTRY DllMain( HANDLE hModule,
        ......

C/C++ 中的移位操作拾遗

引言
最近笔者一直在做JPEG的解码工作,发现用完全使用哈夫曼树进行解码比较费时,而使用表结构存储编码和值的对应关系比较快捷,但是也存在比较难处理的地方,比如解码工作通常是以位为单位的操作,这里必然会涉及到移位操作,而笔者之前对位的操作很少,经验很欠缺,经过这次历练终于发现了一个自己曾经忽视的东西,那就 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号