#include<iostream>
using namespace std;
int str_size(char *str)
{
char *pbegin;
char *pend;
pend=str;
while(*pend!='\0')
{
pend++;
}
pend--;
pbegin=pend;
int siz=0;
while(*pbegin!=' ')
{
pbegin--;
siz++;
}
return siz;
}
int main()
{
char str[]="hello world";
int size=str_size(str);
cout<<"the size of last word is: "<<size<<endl;
return 0;
}
using namespace std;
int str_size(char *str)
{
char *pbegin;
char *pend;
pend=str;
while(*pend!='\0')
{
pend++;
}
pend--;
pbegin=pend;
int siz=0;
while(*pbegin!=' ')
{
pbegin--;
siz++;
}
return siz;
}
int main()
{
char str[]="hello world";
int size=str_size(str);
cout<<"the size of last word is: "<<size<<endl;
return 0;
}