码迷,mamicode.com
首页 > 其他好文 > 详细

删除字符串头部的空白字符

时间:2016-01-22 22:03:49      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

#include <stdio.h>
#include <string.h>

 //删除字符串头部的空白字符。
int main()
{
	char code[]="        hello  World";		//
	int len=sizeof(code);

	char buf[16];
	int count=0;
	int i=0;
	for(i=0;i<len;i++)
	{
		if(code[i]==‘ ‘)
		{																				   					  
				continue;																				 
		}																																	 
		else
		{
		   for(int j=i;j<len;j++)				  
		   {
			   buf[count++]=code[j];																  
		   }
		   break;
		}																								 
	}	

	return 0;
}

  

#include <stdio.h>
#include <string.h>

 //删除字符串头部的空白字符。
int main()
{
    char code[]="        hello  World";        //
    int len=sizeof(code);

    char buf[16];
    int count=0;
    int i=0;
    for(i=0;i<len;i++)
    {
        if(code[i]== )
        {                                                                                                         
                continue;                                                                                 
        }                                                                                                                                     
        else
        {
           for(int j=i;j<len;j++)                  
           {
               buf[count++]=code[j];                                                                  
           }
           break;
        }                                                                                                 
    }    

    return 0;
}

 

删除字符串头部的空白字符

标签:

原文地址:http://www.cnblogs.com/Shenniu/p/5152286.html

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