?
Solved

Empty and null string

Posted on 2001-06-30
5
Medium Priority
?
342 Views
Last Modified: 2010-04-06
Hi
I'm a bit confused when the Win32 sdk talks about that a string should be empty or null.
Could somebody clear things up.

if a pchar is assigned to nil then it is a null string ?
if it's an empty string then ..
0
Comment
Question by:bnz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 14

Accepted Solution

by:
AvonWyss earned 200 total points
ID: 6240488
Windows uses Zero-Terminated (also called C-Style) strings. They are terminated with a #0 char. So, if you have a PChar pointing to a #0, it points to an empty string. If you have a PChar pointing to nil, it's NULL...
0
 
LVL 2

Expert Comment

by:bugroger
ID: 6240497
Hi,

var
 ts : pchar;

begin
 //before ts set to '' ts is nil = NULL string
 ts := '';
 //after ts set to '' ts is an empty string
 //-> "pointing to a #0"
0
 

Author Comment

by:bnz
ID: 6240507
is '' equal #0 ?
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6240534
bnz, Zero-Terminated strings are terminated by #0. So if you have an empty string, the PChar will therefore point to a #0 (that is, there are no other chars between the beginning of the string and the #0 terminating the string). Because of this, Delphi will substitute '' to a pointer pointing to a #0.
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6240535
(but be aware that '' on other string types than Zero-Terinated will NOT point to a #0; for instance, the Delphi ANSI strings will be set to nil if '' is assigned!)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question