//字符反向排列
//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. UVA 10622 - Perfect P-th Powers(数论)

    UVA 10622 - Perfect P-th Powers 题目链接 题意:求n转化为b^p最大的p值 思路:对n分解质因子,然后取全部质因子个数的gcd就是答案,可是这题有个坑啊.就是输入的能够 ...

  2. chrome查看headers

    F12-> network标签, 刷新网页-> 找到该网页url,选择headers

  3. webmagic加上了注解支持

    今天有个网友在博客回帖,能不能用注解来写一个爬虫?想了想,因为Javaer总习惯结果有个对象Model(我在自己用的时候也是这样),ResultItems的key-value形式难免会有点麻烦,何不将 ...

  4. UVALive 6869(后缀数组)

    传送门:Repeated Substrings 题意:给定一个字符串,求至少重复一次的不同子串个数. 分析:模拟写出子符串后缀并排好序可以发现,每次出现新的重复子串个数都是由现在的height值减去前 ...

  5. 快速学会搭建SVN服务器

    原文:快速学会搭建SVN服务器 SVN是一个版本控制工具,常用于我们软件开发项目中,用来管理我们团队共同使用的代码,文档等历史版本的管理,保持代码的更新,避免混乱. 需要工具: svn安装程序:免费下 ...

  6. 1T文件夹 - 微云

    1T文件夹 - 微云 1T文件夹

  7. hello MemSQL 入门安装演示样例

    一,介绍 MemSQL号称世界上最快的分布式关系型数据库,兼容mysql但快30倍,能实现每秒150万次事务.原理是仅用内存并将SQL预编译为C++. 二,部署 官网下载地址:http://www.m ...

  8. HTTPS原理(转)

    HTTPS是什么 HTTPS全称为Hypertext Transfer Protocol over Secure Socket Layer,及以安全为目标的HTTP通道,简单说就是HTTP的安全版本. ...

  9. xcode多target

    原文:http://www.codza.com/free-iphone-app-version-from-the-same-xcode-project There are more than 15,0 ...

  10. nginx学习12 ngx_cycle_t 和 ngx_init_cycle

    在nginx在启动过程,ngx_init_cycle这个函数最初始工作.变量的初始化存储在ngx_cycle_t这个结构体中,为了深入了解这个函数都做了那些初始化工作,就化时间研究了一下.并写下来以便 ...