views:

321

answers:

2

Hello,

Excuse my ignorance, but I don't know what the phrase means. I have a few questions:

  1. is there any difference between 'string is not terminated' and 'string is not null terminated'?
  2. What is it?
  3. How does a non terminated string look like?

Thank you!

+1  A: 

"string not terminated" usually means you are missing the closing quote for your string.

Tundey
+10  A: 

It depends on the context. When someone talks about a string being null-terminated, they usually are talking about a C-style string, which is simply an array of characters, followed by a 0-byte at the end, sometimes refered to as \0 or null.

This stands in contrast to string datatypes which instead store their length at the beginning, and then an array of characters. In this case, the string "yo!" would be represented as:

Length  Char0 Char1 Char2
------  ----- ----- -----
  3       y     o     !

When someone talks about a string "not being terminated", they're usually talking about a string that is not enclosed by two sets of quotes -- this is the kind of error a compiler will give you. It's a totally different thing.

Dave Markle