//字符反向排列
//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. data URI scheme及其应用

    data URI scheme通俗的来讲就是将一张图片直接塞到HTML中而不是通过HTTP请求去获取.这样从表面上看会降低一次HTTP的请求,实现了对于网页的优化(只是看了其它一些文章data URI ...

  2. NET单元测试的艺术

    NET单元测试的艺术 开篇:上一篇我们学习基本的单元测试基础知识和入门实例.但是,如果我们要测试的方法依赖于一个外部资源,如文件系统.数据库.Web服务或者其他难以控制的东西,那又该如何编写测试呢?为 ...

  3. 开启cocos2dx 3.0的Console功能

    下面内容用于自己知识的备忘,想看具体内容,请參照例如以下地址. 原英文文地址: http://discuss.cocos2d-x.org/t/cocos3-0-tutorial-console-tut ...

  4. POJ 3696 神TM数论

    鸣谢: http://blog.csdn.net/yhrun/article/details/6908470 http://blog.sina.com.cn/s/blog_6a46cc3f0100tv ...

  5. Jquery节点遍历

    jquery 节点遍历 <html> <head> <title></title> <script src="Jquery/jquery ...

  6. python语言学习7——数据类型和变量

    整数 python可以处理任意大小的整数,包括负整数,在程序中的表示方法和数学上的写法一样 计算机由于使用二进制,有时候采用十六进制表示整数比较方便,十六进制数用0x前缀 浮点数 简单的小数就直接用小 ...

  7. Android_多媒体_SoundPool声音池使用

    1.SoundPool概述 SoundPool就相当于一个简单的集合,可以将apk中的资源或者系统中的文件加载至内存中,使用了MediaPlayer服务区解码音频文件,用SoundPool可以播一些短 ...

  8. 微信简单Demo

    新建一个WxHandler.ashx public class WxHandler : IHttpHandler { public static string Msg; public void Pro ...

  9. Linux下忘记rootpassword怎么办?

    1.首先确认server出于安全的状态.也就是没有人可以随意地连接MySQL数据库. 由于在又一次设置MySQL的rootpassword的期间,MySQL数据库全然出于没有password保护的  ...

  10. myeclipse中,项目上有个叉报错,文件没有错误

    同事将他的java项目交接给了我.和平时的交接一样.他把他最新的源码.打成压缩包,发给我. 我解压后.使用myeclipse开发工具.通过导入,将项目导入到我的开发工具中.这个时候有一个问题出现了.在 ...