M
MikeC
Folks,
I just wrote a little function to find the end of a line:
char *eol(char *pt)
{ while(*pt != '\r' && *pt != '\n' && *pt != '\0') // run along to the line
terminator character
pt++;
return pt; // and return a pointer to it
}
I use it thus:
main() // I know, I know!
{ char text_line[260], *t_pt;
/* [ get a file path into text_line] */
t_pt = eol(text_line);
*t_pt = '\0'; // this knocks off a '\n', which stops chdir() from
working
chdir(text_line);
}
This works fine, but just for the experiment, I replaced the two lines
containing t_pt with
*eol(text_line) = '\0';
.... and it worked. Is this a syntactical thing to do? Is it portable? I'd
appreciate your educated comment on this.
Thanks a heap,
MikeC.
--
Mental decryption required to bamboozle spam robots:
mike_best$ntlworld*com
$ = @
* = dot
I just wrote a little function to find the end of a line:
char *eol(char *pt)
{ while(*pt != '\r' && *pt != '\n' && *pt != '\0') // run along to the line
terminator character
pt++;
return pt; // and return a pointer to it
}
I use it thus:
main() // I know, I know!
{ char text_line[260], *t_pt;
/* [ get a file path into text_line] */
t_pt = eol(text_line);
*t_pt = '\0'; // this knocks off a '\n', which stops chdir() from
working
chdir(text_line);
}
This works fine, but just for the experiment, I replaced the two lines
containing t_pt with
*eol(text_line) = '\0';
.... and it worked. Is this a syntactical thing to do? Is it portable? I'd
appreciate your educated comment on this.
Thanks a heap,
MikeC.
--
Mental decryption required to bamboozle spam robots:
mike_best$ntlworld*com
$ = @
* = dot