码迷,mamicode.com
首页 > 编程语言 > 详细

C语言 去掉字符串最后的 *

时间:2014-09-09 13:50:39      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:c语言   字符串   

#include<stdio.h>

#include<conio.h>

void proc(char *str)

{

    while(*str !=‘\0‘)

    str++;  //将指针移到最后一位

    str--;

    while(*str ==‘*‘)

    str--;

    *(str+1) = ‘\0‘;  //添加结束符

}


void main()

{

    char s[17]={"****asd***fff***"};

    puts(s);

    printf("\n");

    proc(s);

    puts(s);

}


C语言 去掉字符串最后的 *

标签:c语言   字符串   

原文地址:http://taiyi928.blog.51cto.com/7898859/1549879

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!