C语言笔试题(1)——将字符串对调显示

来源:互联网 发布:单据打印软件免费版 编辑:程序博客网 时间:2024/04/30 02:43
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>void reverse(char *str){     char len = 0;     char *p_top, *p_end;     char temp;     assert(str != NULL);     len = strlen(str);                p_top = str;     p_end = str + len - 1;     while(p_top < p_end)     {           temp = *p_top;           *p_top = *p_end;           *p_end = temp;           p_top++;           p_end--;     }}int main(void){     char str[] = "ABCD1234efgh";     reverse(str);     printf("%s\n",str);}