//字符反向排列
//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. 《转》Linux下的多线程编程

    原地址:http://linux.chinaunix.net/doc/program/2001-08-11/642.shtml 1 引言 线程(thread)技术早在60年代就被提出,但真正应用多线程 ...

  2. 开源mp3播放器--madplay 编译和移植 简记

    madplay是一款开源的mp3播放器. http://madplay.sourcearchive.com/ 下面简单记录一下madplay的编译与移植到ARM开发板上的过程 一.编译x86版本的ma ...

  3. nginx源代码分析--event事件驱动初始化

    1.在nginx.c中设置每一个核心模块的index ngx_max_module = 0; for (i = 0; ngx_modules[i]; i++) { ngx_modules[i]-> ...

  4. poj1860(spfa判正环)

    题目连接:http://poj.org/problem?id=1860 题意:有多种从a到b的汇率,在你汇钱的过程中还需要支付手续费,那么你所得的钱是 money=(nowmoney-手续费)*rat ...

  5. hdu2102(bfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2102 分析:bfs求最短时间到达'P'点,不过本题有好几个trick,我都踩到了,自己还是太嫩了... ...

  6. Java反射机制小例子

    package com.wjy.main; import java.io.Console; import java.lang.reflect.Constructor; import java.lang ...

  7. 《Java并发编程实战》第七章 取消与关闭 读书笔记

        Java没有提供不论什么机制来安全地(抢占式方法)终止线程,尽管Thread.stop和suspend等方法提供了这种机制,可是因为存在着一些严重的缺陷,因此应该避免使用. 但它提供了中断In ...

  8. c++ 对象指针参数和对象引用参数02

    对象指针作为函数参数和对象引用作为函数参数都比对象作为函数参数要用的更为普遍 传对象指针和传对象引用作为实参,那么实参在函数里发生了变话,那么相应的对象本身也会发生变化,二传递对象本身作为实参的话,实 ...

  9. 自定义Annotation

    来源:http://blog.csdn.net/lifetragedy/article/details/7394910 概念篇 来看一个最简单的annotation示例 @Target(Element ...

  10. java性能缓慢

    虚拟帝国上面有很多营销软件是JAVA开发的!创业公司通常选择开源技术减少项目管理费用. 除了使用Java编程语言,创业公司也可以利用Java开发工具包的好处(JDK),Java运行时环境(JRE)和J ...