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

#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;
}

 

posted @ 2016-01-22 20:43  爱蜗牛的神牛  阅读(391)  评论(0编辑  收藏  举报