What Does Null Mean in C, C++ and C#? (2024)

Null Is Both a Constant and a Pointer in Computer Programming

What Does Null Mean in C, C++ and C#? (1)

By

David Bolton

Computer Science Expert

  • B.A., Computer Science, Queen's University Belfast

David Bolton is a software developer who has worked for several major firms, including Morgan Stanley, PwC, BAE Systems, and LCH.

Learn about ourEditorial Process

Updated on April 27, 2019

In computer programming, null is both a value and a pointer. Null is a built-in constant that has a value of zero. It is the same as the character 0 used to terminate strings in C. Null can also be the value of a pointer, which is the same as zero unless the CPU supports a special bit pattern for a null pointer.

What Is a Null Value?

In a database, zero is a value. The value null means that no value exists. When used as a value, null is not a memory location. Only pointers hold memory locations.Without a null character, a string would not correctly terminate, which would cause problems.

What Is a Null Pointer?

The C and C++ programming, a pointer is a variable that holds a memory location. The null pointer is a pointer that intentionally points to nothing. If you don't have an address to assign to a pointer, you can use null. The null value avoids memory leaks and crashes in applications that contain pointers. An example of a null pointer in C is:

#include
int main()
{
int*ptr = NULL;
printf("The value of ptr is %u",ptr);
return 0;
}

Note: In C, the null macro may have the type void* but this is not allowed in C++.

Null in C#

In C#, null means "no object." Information about null and its usages in C# include:

  • You cannot use 0 instead of null in your programs even though null is represented by the value 0.
  • You can use null with any reference type including arrays, strings, and custom types.
  • In C#, null is not the same as the constant zero.

Format

mlaapachicago

Your Citation

Bolton, David. "What Does Null Mean in Computer Programming?" ThoughtCo, Sep. 8, 2021, thoughtco.com/definition-of-null-958118.Bolton, David. (2021, September 8). What Does Null Mean in Computer Programming? Retrieved from https://www.thoughtco.com/definition-of-null-958118Bolton, David. "What Does Null Mean in Computer Programming?" ThoughtCo. https://www.thoughtco.com/definition-of-null-958118 (accessed September 16, 2024).

What Does Null Mean in C, C++ and C#? (2024)
Top Articles
Place a ChexSystems Security Freeze
Learn to Scuba Dive with Confidence: Answers to 13 Scuba Diving FAQs
Will Byers X Male Reader
Cranes For Sale in United States| IronPlanet
Craigslist Warren Michigan Free Stuff
Ffxiv Palm Chippings
فیلم رهگیر دوبله فارسی بدون سانسور نماشا
Kraziithegreat
Top 10: Die besten italienischen Restaurants in Wien - Falstaff
Boggle Brain Busters Bonus Answers
Konkurrenz für Kioske: 7-Eleven will Minisupermärkte in Deutschland etablieren
라이키 유출
1TamilMV.prof: Exploring the latest in Tamil entertainment - Ninewall
Becky Hudson Free
Edgar And Herschel Trivia Questions
Sitcoms Online Message Board
What Does Dwb Mean In Instagram
Https://Gw.mybeacon.its.state.nc.us/App
Marion County Wv Tax Maps
Napa Autocare Locator
Gemita Alvarez Desnuda
360 Tabc Answers
Sunset Time November 5 2022
kvoa.com | News 4 Tucson
Watson 853 White Oval
Miles City Montana Craigslist
Effingham Daily News Police Report
Dell 22 FHD-Computermonitor – E2222H | Dell Deutschland
24 Hour Drive Thru Car Wash Near Me
2487872771
Rubmaps H
Learn4Good Job Posting
Microsoftlicentiespecialist.nl - Microcenter - ICT voor het MKB
Where Do They Sell Menudo Near Me
Linabelfiore Of
Samsung 9C8
Polk County Released Inmates
Elgin Il Building Department
Maxpreps Field Hockey
Banana Republic Rewards Login
Walgreens Agrees to Pay $106.8M to Resolve Allegations It Billed the Government for Prescriptions Never Dispensed
Entry of the Globbots - 20th Century Electro​-​Synthesis, Avant Garde & Experimental Music 02;31,​07 - Volume II, by Various
Ukraine-Krieg - Militärexperte: "Momentum bei den Russen"
M&T Bank
Killer Intelligence Center Download
Wpne Tv Schedule
Dying Light Mother's Day Roof
Mcoc Black Panther
Acuity Eye Group - La Quinta Photos
Craigslist Free Cats Near Me
Call2Recycle Sites At The Home Depot
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6328

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.