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++这样自由度非常大的编程语言,几乎是每一个用其开发出来的软件都会出现内存泄漏的情况。
如果没有内存泄漏,世界或许会变的美好。然而,完全美好的世界是不存在的,我们能做的就是尽量让它变的更美 ......
C、传统 C++
#include <stdio.h> //定义输入/输出函数
#include <stdlib.h> //定义杂项函数及内存分配函数
#include <string.h> //字符串处理
#include <assert.h> //设定插入点
#include <ctype.h> //字符处理
#include <errno.h&g ......
用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,
......