Solved

Empty and null string

Posted on 2001-06-30
5
336 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
  • 3
5 Comments
 
LVL 14

Accepted Solution

by:
AvonWyss earned 50 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi prevent click fast 2 220
Correct Component for Shopping Cart. 2 105
Convert MS Word document to a PDF file 9 82
can i put an image from resource into image tag ? 6 25
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

803 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