VC++ 字符串赋值例子
来源:互联网 发布:思迅软件u盘 编辑:程序博客网 时间:2024/04/29 16:00
可能是比较常用的字符串赋值的例子:
#include "stdafx.h"#include <iostream>#include <vector>#include <string.h>using std::cout;using std::endl;using std::vector;char* firstname;char* lastname;void initName(const char* first, const char* second);int main(int argc,_TCHAR* argv[]){char* fName("John");char* lName("Smith");initName(fName,lName);return 0;}void initName(const char* first, const char* second){size_t length(strlen(first)+1);firstname = new char[length];strcpy_s(firstname,length,first);length = strlen(second)+1;lastname = new char[length];strcpy_s(lastname,length,second);cout<<"firstname:"<<firstname<<endl<<"lastname:"<<lastname<<endl;}
最后输出结果为:
firstname:John
lastname:Smith
请按任意键继续. . .
0 0
- VC++ 字符串赋值例子
- VC++ 字符串赋值例子(2)
- 字符串赋值
- 字符串赋值
- VC++IP控件赋值
- VC中IP控件字符串IP的赋值与取值
- VC中IP控件(CIPAsressCtr)字符串IP的赋值与取值
- 对事件‘赋值’的例子
- rdd中赋值操作例子
- 字符串的赋值
- 关于字符串赋值
- 给字符串数组赋值:
- string字符串-赋值
- 字符串赋值问题
- 汇编字符串赋值详解
- 宽字符串赋值
- PHP字符串赋值
- 字符串赋值怎么不行
- 每隔3位添加一个逗号
- 逻辑回归的深入理解总结
- Fragment+RadioGroup实现底部菜单栏(二)
- iOS开发多线程篇—GCD介绍
- 《开源框架那点事儿11》:软件开发杂谈
- VC++ 字符串赋值例子
- COM一些小知识
- 学生信息管理系统收宫篇
- CSS样式表层叠(cascade)处理冲突
- 设置千分位格式显示
- html jquery 相册资源搜集
- Tomcat服务器的使用(一)
- Ubuntu 9.10 编译 Xephyr
- sleep() 和 wait() 有什么区别?