0

I accept string from a user then print split string words using space and print it inside a function at second iteration pch="*" but when it is called inside main it still has select.

How to make change in function appear in main function?

void moveNext(char * pch)
{           
    pch=strtok(NULL," ");        
}

int main()
{

    char * str;
    clrscr();

    printf("\n please enter sql comm.....\n");
    flushall();
    gets(str);
    //user has enterd that string select * from std
    pch = strtok(str," ");
    while(pch != NULL)
    {
         printf("%s",pch);
         moveNext(pch);
    }

    getch();
    return 0;
}
chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256

1 Answers1

0

The below code will help you to get rid of the function movenext

int main()
{
   char *p; 
   char a[20];
   printf("ENter name:\n");
   fgets(a,20,stdin);

   p = strtok(a," ");
   while( p  != NULL)
   {   
      printf("%s ",p);
      p = strtok(NULL," ");
   }   
}
Gopi
  • 19,784
  • 4
  • 24
  • 36