From: George P. <geo...@ci...> - 2009-08-31 05:09:03
|
Am I doing something wrong here? gettokens on an empty string appears to generate an array of length 1, but if I loop over that array, it behaves like it's of length 0. Here's the code: auto line; auto f; auto word; while (line = getline()) { printf("<%s>", line); f = sopen(line); line = gettokens(f); close(f); printf("<%d>\n", nels(line)); forall (word in line) printf("<<<%s>>>", word); put("\n"); } Here's the input--three lines, the middle one empty: hello there we would like Here's the output: <hello there><2> <<<hello>>><<<there>>> <><1> <we would like><3> <<<we>>><<<would>>><<<like>>> -- George Politis (geo...@ci...) Principal Software Engineer Canon Information Systems Research Australia |