Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

what is the difference between null terminated string and string

0 views
Skip to first unread message

brian

unread,
Jul 19, 2001, 8:00:24 AM7/19/01
to
what is the difference between null terminated string and string.

some parameters of a function are defined to be null terminated strings
and some just string. what's the difference ?

Jens Knoell

unread,
Jul 20, 2001, 10:12:07 PM7/20/01
to
Strings are just characters chained together, not necessarily with a defined
length. You could, for example, also hold picture data in a string. A null
terminated string has a special "end of string" delimiter - as the name
implies, its the \0 character. Thus you can't hold data in a null terminated
string which has in itself a null character.

Jens

"brian" <brian_...@yahoo.com> schrieb im Newsbeitrag
news:a74ee6e1.01071...@posting.google.com...

Norman Bullen

unread,
Jul 20, 2001, 10:51:35 PM7/20/01
to

A NUL terminated string has an ASCII or Unicode NUL character after the
last character of text. A NUL is a char (ASCII) equal to '\0' or an int
(Unicode) equal to 0.

An string that is not specified to be NUL terminated does not need to
have a NUL character at the end of it; some other mechanism will be used
to determine the length of the string.

The only case I can think of off hand where Windows uses a string that
does NOT need to be NUL terminated is the TextOut() function. In other
cases you should assume that a NUL terminator is required.

Norm

Norman Bullen

unread,
Jul 21, 2001, 10:11:15 AM7/21/01
to
Norman Bullen wrote:
>
> brian wrote:
> >
> > what is the difference between null terminated string and string.
> >
> > some parameters of a function are defined to be null terminated strings
> > and some just string. what's the difference ?
>
> A NUL terminated string has an ASCII or Unicode NUL character after the
> last character of text. A NUL is a char (ASCII) equal to '\0' or an int
> (Unicode) equal to 0.

I should have said short int above.

0 new messages