#import "string.h"
const int COUNTS_OF_LINE = 93;
void cpytoend(char* str, char* pstart, char* pend)
{
while (pstart != pend + 1)
{
*str = *pstart == '\n'? ' ': *pstart;//对换行符进行特殊处理
pstart++;
str++;
}
*str = '\0';
}
BOOL isEnd(char c)
{
if (c == ' ' || c == ',' || c == '.')//可作为换行的标识字符
{
return YES;
}
else
{
return NO;
}
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
char strContent[2048] = {0};
NSString * astring = The Remote Controller is an application that turns your iPad, "
"iPhone or iPad touch into a remote control for your IPTV. \n"
"jk's vision is to enrich people's lives through communication. By leveraging our experience and"
"expertise in telecom sector,we help bridge the digtal "
"digital divide and give people the opportunity to join the information age,regardless og their geographic origin. In order to tackle increasing
climate "
"challenges, jk has deployed a wide range of green solutions that enable customers to reduce power consumption and carbon emissions, contributing
to the "
"sustainable develoopment of the social economy and the environment.";
strcpy(strContent, [astring UTF8String]);
char * pchstart = strContent;
char * pend = pchstart;
int number = 0;
while (*pend != '\0')
{
if (number < COUNTS_OF_LINE)
{
if ( *pend == '\n' || *(pend + 1) == '\0')
{
char tmpstr[100] = {0};
cpytoend(tmpstr, pchstart, pend);
NSLog(@"======%s", tmpstr);
pchstart = pend + 1;
number = 0;
}
}
else
{
if (isEnd(*pend) )
{
char tmpstr[100] = {0};
cpytoend(tmpstr, pchstart, pend);
NSLog(@"======%s", tmpstr);
pchstart = pend + 1;
number = 0;
}
}
number++;
pend++;
}
}