Suppose you want to split the string at the point where the space occurs. The two substrings are being stored in string2 and string3, while string1 is the main string.
Code:
#include<stdio.h>
#include<string.h>
#define MAX 50
int main()
{
char string1[MAX],string2[MAX],string3[MAX];
int ctr1,ctr2,ctr3;
gets(string1);
ctr1=0;
while(string1[ctr1]!=' ')
{
string2[ctr1]=string1[ctr1]; ++ctr1;
}
ctr3=0;
for(ctr2=ctr1+1; ctr2<strlen(string1); ++ctr2)
{
string3[ctr3]=string1[ctr2]; ++ctr3;
}
return(0);
}