//字符反向排列
//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. 通过Type.InvokeMethod实现方法的重载

    版本:.NET Framework 3.5 先来一个反射调用方法的例子: using System; using System.Reflection; class Example { static v ...

  2. MVC多语言应用

    MVC多语言应用 最近发现资源文件是个好东西, 用的好了可以给开发人员借阅不少的时间. 例如做一个多语言的网站, 资源文件就有不小的用处. 这里以MVC4模版项目的登录页为例, 简单说一下过程: 1. ...

  3. 应用层open(read、write、close)怎样调用驱动open(read、write、close)函数的?

    应用层open(read.write.close)怎样调用驱动open(read.write.close)函数的? 华清远见2014-09-29   北京海淀区 张俊浩 三大数据结构关系图

  4. HDU 2255 奔小康,赚钱(KM算法模板)

    解决问题的思路: 二部图,正确的匹配,卡费用流,使用KM算法. #include <cstring> #include <algorithm> #include <cst ...

  5. Android 的Google+平台

    Google+是谷歌推出的身份服务和社交网站.也是Google各种服务社交层面的补强.是世界上第二大的社交网站.一旦用户登录到Google,你就可以按照自己的需要定制服务和使用你的应用程序.

  6. atitit.团队建设--要不要招技术储备人才的问题

    atitit.团队建设--要不要招技术储备人才的问题 1.      人才的储备和招聘. 1 1.1.   模式1.     养兵千日,用兵一时 1 1.2. 模式2,暂时抱佛脚,也不多招一个人 1 ...

  7. java设计模式_单例

    public class Singleton { public static void main(String[] args) throws Exception { System.out.printl ...

  8. emeditor只显示特定类型的文件

    emeditor过滤文件类型,右侧资源管理器中只显示特定类型的文件,如只显示java,xml,txt,properties等文件,而不显示doc,jpg,xls等emeditor不能打开的文件. 右击 ...

  9. Ucan23操作系统项目地址

    期间耽误了近半年的时间.在昨天最终完毕了Ucan23OS, 项目托管在GitHub上,地址为: https://github.com/howardking/UCAN23OS 以下为操作系统的执行截图 ...

  10. Swift 的类、结构体、枚举等的构造过程Initialization(下)

    类的继承和构造过程 类里面的全部存储型属性--包含全部继承自父类的属性--都必须在构造过程中设置初始值. Swift 提供了两种类型的类构造器来确保全部类实例中存储型属性都能获得初始值,它们各自是指定 ...