//# include<stdio.h>
void function();
main()
{
function();
}
void function()
{
int i,index,k,m;
char str1[100],retry,str[100],*ptr,*ctr;
int j=0;
printf("enter the string");
fgets(str, sizeof(str), stdin);
if((ptr = strchr(str, '\n')) != NULL)
*ptr = '\0';
printf("enter the string to be compared");
fgets(str1, sizeof(str1) , stdin);
if((ctr = strchr(str1, '\n')) != NULL)
*ctr = '\0';
/* printf("enter index"); */
/* canf("%d",& index); */
char *ch,*pch;
ch=strtok(str,":");
printf(" ratg");
if (ch==NULL)
{
printf("entered string is incorrect,reenter? y/n");
scanf("%s",&retry);
if(retry=='y')
function();
else return;
}
else
printf("\nch is NULL\n");
while(ch!=NULL)
{
pch=strstr(ch,";");
i=pch-ch;
/* strncpy(tr[j].member1,ch,i); */
/* strcpy(tr[j].member2,pch+1); */
j++;
ch=strtok(NULL,":");
}
i tried your code . yes it is not giving any segmentation error but it is not performing desired operation
first of all it is giving a warning:
assignment makes pointer from integer without a cast
for statements 23 and 42
then it is not going inside the loop for asking the user if he wants to enter again the string
i am working on linux , i hope this is not creating any problems
i will be posting a reconstructed program of mine for your convinience