Runtime error when reversing string in C -


i don't understand why getting runtime error when use s[j]!='\0' when use *temp!='\0' works fine. can explain?

void reversewords(char *s) {   char *word_begin = s;   char *temp = s; /* temp word boundry */   int i=0,j=0;    while( s[j]!='\0' )   {     j++;     if (s[j] == '\0')     {       reverse(s, i, j-1);     }     else if(s[j] == ' ')     {       reverse(s, i, j-1);       = j+1;     }   }      } 

the error not in function. if check reverse function, never increment i or decrement j run forever.

a debugger helpful tool , have shown immediately.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -