// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(){
char src[]="source";
char tar[3];
printf("sizeof(tar)=%d/n",sizeof(tar));
strcpy(tar,src);
printf("sizeof(tar)=%d/n",sizeof(tar));
printf("strlen(tar)=%d/n",strlen(tar));
printf("%s/n",tar);
}
本文通过一个简单的C++程序示例介绍了如何使用标准库函数处理字符串,包括字符串复制(strcpy)和获取字符串长度(strlen)。示例展示了基本的字符串操作,并通过打印sizeof运算符的结果来说明数组大小的概念。

被折叠的 条评论
为什么被折叠?



