标签:
#include <stdio.h>
int getLength(char *string);
int main(int argc, char **argv)
{
char str[12] = "hello0world";
char *str1, *str2;
int i = 0;
int len, len2;
char *p_str = str;
len = getLength(str);
while (i++ < len)
{
str1 = p_str++;
str1++;
if (*p_str == ‘0‘)
{
*str1 = ‘\0‘; // end of string
len2 = i; // get the i when p_str point to ‘0‘
str2 = ++p_str;
while (len2--)
str1--;
break;
}
}
printf ("---After split----\n");
printf ("str1: %s\n", str1);
printf ("str2: %s\n", str2);
return 0;
}
int getLength(char *string)
{
int len = 0;
while (*string++)
len++;
return len;
}
标签:
原文地址:http://www.cnblogs.com/201112701206lee/p/4788187.html