//字符反向排列
//vision 1.2
#include<stdio.h> void reverse_string( char *str )
{
char *string;//第一个字符位置
char *last_char;//最后一个字符位置 //for( last_char = str; ; last_char++ )
// if( *last_char == '\0' )
// break;
// for( last_char = str; *last_char != '\0'; last_char++ )
// ; /*
**设置last_char存储最后一个字符位置
*/
for( last_char = &str[0]; *last_char != '\0'; last_char++ )
; string = &str[0];
last_char--; /*
**交换前后指针指向位置的值 前指针添加 后指针降低
*/
while( string < last_char )
{
char temp;
temp = *string;
*string++ = *last_char;
*last_char-- = temp;
} printf( "%s", str );
} int main( void )
{
char str[10] = {"abcdef"};
reverse_string(str);
return 0;
}

在不使用库函数情况下 自己还是把这个库函数里有的函数敲出来了。仅仅是有个迷惑的地方。这是终究版本号,但之前有个版本号,输出始终仅仅有源字符串的一半长度。同一时候也是反转了的。不理解。

希望有明确的朋友看见后能够告知下。小子我在此谢谢了~源代码例如以下:

//字符反向排列
//vision 1.2
//程序结果错误 为什么?
//就眼下 我推測问题出在数组的指针上
//直接对原数组的指针进行操作 应该找个中间量存储開始指针。
//未完待续····
#include<stdio.h> void reverse_string( char *str )
{
char *last_char;//最后一个字符位置 //for( last_char = str; ; last_char++ )
// if( *last_char == '\0' )
// break;
// for( last_char = str; *last_char != '\0'; last_char++ )
// ; /*
**设置last_char存储最后一个字符位置
*/
for( last_char = &str[0]; *last_char != '\0'; last_char++ )
; last_char--; /*
**交换前后指针指向位置的值 前指针添加 后指针降低
*/
while( str < last_char )
{
char temp;
temp = *str;
*str++ = *last_char;
*last_char-- = temp;
} printf( "%s", str );
} int main( void )
{
char str[10] = {"abcdxuf"};
reverse_string(str);
return 0;
}

仅仅是多了个中间变量而已,这是为什么呢?

The practice program of C on point的更多相关文章

  1. [Chapter 3 Process]Practice 3.12 Including the initial parent process, how many processes are created by the program shown in Figure 3.32?

    3.12 Including the initial parent process, how many processes are created by the program shown in Fi ...

  2. [Chapter 3 Process]Practice 3.2 Including the initial parent process, how many processes are created by the program shown in Figure?

    3.2 Including the initial parent process, how many processes are created by the program shown in Fig ...

  3. 2015年第2本(英文第1本):《The Practice of Programming》

    2015年计划透析10本英文原著,最开始选定的第一本英文书是<Who Moved my Cheese>,可是这本书实在是太短.太简单了,总体的意思就是要顺应变化,要跳出自己的舒适区,全文不 ...

  4. regardless of how many processors are devoted to a parallelized execution of this program

    https://en.wikipedia.org/wiki/Amdah's_law Amdahl's law is often used in parallel computing to predic ...

  5. 汉企C#面向对象——继承Practice

    class Dianqi //创建电器类:父类 { private string _Dianqimingzi; public string Dianqimingzi { get { return _D ...

  6. Book Review of “The practice of programming” (Ⅳ)

    The practice of programming Chapter 4 Interfaces A good programmer should always be good at designin ...

  7. ConCurrent in Practice小记 (4)

    ConCurrent in Practice小记 (4) Executors Callable && Future <T> Callable:此接口有一个call()方法. ...

  8. PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...

  9. 南京大学 静态软件分析(static program analyzes)-- introduction 学习笔记

    一.Programming Languages体系 静态程序分析是编程语言中应用层面下的一个细分领域,它是一个非常重要的核心内容. 在理论部分,考虑的是如何设计一个语言的语法和语义,如何设计语言的类型 ...

随机推荐

  1. System单元对所有与COM相关的声明就这么多,需要倒背如流

    是首先是VM表,但是和COM相关的函数地址都废弃了,这几个VM函数具体放在哪里,还得在研究: { Virtual method table entries } vmtSelfPtr = -; vmtI ...

  2. HDU 4597 Play Game 2013 ACM-ICPC吉林通化全国邀请赛H题

    九野的博客,转载请注明出处:  http://blog.csdn.net/acmmmm/article/details/10833941 题意:给定T个测试数据,下面有2副牌,每副n张,每张都有一个分 ...

  3. 墙体裂缝推荐的情况下驱动的PhoneGap入门,早看早收据

    清华大学出版社推出<构建跨平台APP:PhoneGap移动应用实战> 零门槛的学习APP发展 刮 进步 20以上示范样本APP 3项目APP 台à跨终端à移动开发 完美生命周期:搭建好开发 ...

  4. oracle 之 内存—鞭辟近里(三)

    oracle 之 内存—鞭辟近里(三) 今天是2013-07-08,今天晚上突然接到一个电话,我的外甥问我的qq是多少,我感觉很吃惊,他长大了.在他现在这个年龄就开始接触网络,我难免有少许担心,希望他 ...

  5. Burp Suite抓包、截包和改包

    Burp Suite..呵呵.. 听说Burp Suite是能够监測.截取.改动我们訪问web应用的数据包,这么牛X? 条件:本地网络使用代理.由Burp Suite来代理.也就是说,每一个流出外网的 ...

  6. hdu3853(概率dp)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 题意:有一个人被困在一个 R*C(2<=R,C<=1000) 的迷宫中,起初他在 ( ...

  7. POJ2155:Matrix(二维树状数组,经典)

    Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the ...

  8. Monkey源代码分析之执行流程

    在<MonkeyRunner源代码分析之与Android设备通讯方式>中.我们谈及到MonkeyRunner控制目标android设备有多种方法.当中之中的一个就是在目标机器启动一个mon ...

  9. Linux下精确控制时间的函数

    Linux下精确控制时间的函数 在测试程序接口运行时间的时候,常用time,gettimeofday等函数,但是这些函数在程序执行的时候是耗费时间的,如果仅仅测试时间还行,但是如果程序中用到时间控制类 ...

  10. arcgis jsapi 调用google地区服务

    做地理信息系统(GIS)项目,除了实现功能用户体验度要好之外,最重要的是地图渲染效果更要好.很多时候苦于数据的完整性和对于配图的审美观,程序猿们都很难配出好看的地图效果.基于上述一般直接调用googl ...