The normal meaning of "in place" is only constant additional storage. You're using much more than that.
On Aug 15, 12:52 pm, Don <dondod...@gmail.com> wrote: > #include <ctype.h> > #include <string.h> > > int main(int argc, char* argv[]) > { > char line[500]; > char tmp[500]; > char *words[100]; > int wordCount = 0; > char *p, *wordStart=0; > > printf("Enter string:"); > fgets(line,500,stdin); > > for(p = line; *p; ++p) > { > if (!wordStart && isalpha(*p)) wordStart = p; > else if (wordStart && !isalpha(*p)) > { > words[wordCount++] = wordStart; > *p = 0; > wordStart = 0; > } > } > > p = tmp; > for(int i = wordCount-1; i >= 0; --i) p += sprintf(p, "%s ", > words[i]); > strcpy(line,tmp); > printf(">%s<\n", line); > return 0; > > } > > On Aug 15, 6:18 am, programming love <love.for.programm...@gmail.com> > wrote: > > > > > write a program to reverse the words in a give string. > > also state the time complexity of the algo. > > > if the string is "i am a programmer" > > the output should be "programmer a am i"- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.