#include<iostream>
#include "common.h"
#include<string>
#include <ctype.h>
#include "Calendar.h"
#include <iostream>
#include<boost/date_time.hpp>
#include <boost/lexical_cast.hpp>
using namespace boost::posix_time;
using namespace boost::gregorian;
using namespace std;
struct tagPerson
{
string name;
int age;
}Person;
//去除左边的空格字符
void lTrim(char * str);
//去除右边的空格字符
void rTrim(char * str);
//去除左右两边的空格字符
void Trim(char * str);
void ChangeContentBySP(tagPerson *person);
int main(int argc)
{
char szlName[] = " xiaoming";
char szrName[] = " xiaoming ";
char szName[] = " xiaoming ";
lTrim(szlName);
cout << szlName << endl;
rTrim(szrName);
cout << szrName << endl;
Trim(szName);
cout << szName << endl;
int wait;
cin >> wait;
return 0;
}
void lTrim(char * str)
{
int i , len ;
len = strlen( str ) ;
for( i=0; i<len; i++)
{
if( str[i] != ' ') break ;
}
memmove(str,str+i,len - i + 1); //加1是为了将末尾的'0'也移动
return ;
}
void rTrim(char * str)
{
int i,len ;
len = strlen( str ) ;
for(i = len-1;i>=0;i--)
{
if( str[i] != ' ' ) break ;
}
str[i+1] = 0 ;
return ;
}
void Trim(char * str)
{
int i , len ;
//先去除左边的空格
len = strlen( str ) ;
for( i=0; i<len; i++)
{
if( str[i] != ' ') break ;
}
memmove(str,str+i,len-i+1);
//再去除右边的空格
len = strlen( str ) ;
for(i = len-1; i>=0; i--)
{
if(str[i] != ' ') break ;
}
str[i+1] = 0 ;
return ;
}