A char * is a pointer to a single character. Presumably you mean that the
char * points to the first character in an arbitrarily long sequence, a
sequence which ought to have a null terminator but, for one reason or
another, has not. My answer is based on that understanding.
If you know where the null terminator is supposed to go, you can put one
there. s[n] = '\0';
If you don't, you can't, because a non-null-terminated sequence of chars
will not of itself provide you with that information (in the general
case). I am ignoring clever-clever answers such as:
char arr = "The terminator belongs in place of this trailing colon:";
char *p = arr;
for what I hope are obvious reasons.
So no, you can't hope for the language to tell you where your data ends -
it's your job to know that.
Richard Heathfield < http://www.yqcomputer.com/
Email: -http://www. +rjh@
Google users: < http://www.yqcomputer.com/
"Usenet is a strange place" - dmr 29 July 1999