#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include<string.h> void main() { char * src = "hello,world"; printf("%d", src[10]); char *dest = NULL; //开辟内存空间 然后多开辟一个用来存储字符串的结束符 dest= (char *)malloc(sizeof(char)*(strlen(src) + 1)); int len = strlen(src); char *d = dest; //数组的存储是从 src[0] .. src[10] er len 1....11所以要减去1 char *s = src + len - 1; while (len-- != 0) { *d++ = *src--; } *d = ‘\0‘; system("pause"); }
c语言中字符串的匿置 超级简单,布布扣,bubuko.com
原文地址:http://blog.csdn.net/han1558249222/article/details/25219373