第一种:下标法。
#include<stdio.h> #include<iostream> int main() { //该形式下,字符串实际上是一种字符数组 char str1[] = "hello world",str2[30]; printf("%d ",str1);//获取字符数组首个元素的地址 printf("%s ", str1); int i; //可以利用下标方法复制数组,*(str1+i)表示的是下标为i的值,即str1[i] for (i = 0;*(str1+i)!='