Re: Is this kosher?
- From: "MikeC" <My_address@xxxxxxxxxxx>
- Date: Sat, 11 Nov 2006 00:17:23 GMT
Folks,
My thanks to one and all!
Now I'm a little wiser.
Best regards,
MikeC.
"MikeC" <My_address@xxxxxxxxxxx> wrote in message
news:hF65h.3491$bC3.2937@xxxxxxxxxxxxxxxxxxxxxxx
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
.
- References:
- Is this kosher?
- From: MikeC
- Is this kosher?
- Prev by Date: Re: How to store a 13 digit number in c ?
- Next by Date: mkdir() won't do it for me
- Previous by thread: Re: Is this kosher?
- Next by thread: Hex to Float conversion of GPS Latitude
- Index(es):
Relevant Pages
|