This  is ur solution...

For the sake of simplicity, i hav used arrays instead of pointers.

So plz forgive me if u r keen on using pointers.

well sometimes using of pointers as strings may cause some prob 

as the data of variables in mem may get overwritten.

so i personally avoid using them.







#include <stdio.h>
#include <string.h>

int main()
{
char mywords[]="Hallo,Hi,Hai,Hey";
unsigned int i,j,k;
char myarray[4][10];
clrscr();
i=j=k=0;
for(i=0;mywords[i];i++){
if(mywords[i] ==','){
myarray[j][k]='\0';
i++;
j++;
k=0;
}
myarray[j][k++] = mywords[i];

}
printf("%s\n" ,myarray[ 0]);
printf("%s\n" ,myarray[ 1]);
printf("%s\n" ,myarray[ 2]);
printf("%s\n" ,myarray[ 3]);
getch();
}











Reply via email to