![]() |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 39
| Can you tell me how to check if a string is null in C? I tried p != '\0' doent seem to wrk though! thanks |
| doubty is offline | |
| | #2 |
| Registered User Join Date: Oct 2008
Posts: 450
| Do you want to test if a character array points to NULL or a string is empty? Your wording doesn't make much sense. But the two I said: Code: p == NULL /* True if character array points to NULL */ !*p or *p == '\0' /* True if string empty */ |
| EVOEx is offline | |
| | #3 |
| gcc -Wall -pedantic *.c Join Date: Jan 2009 Location: London
Posts: 52
| Code: char *p=NULL;
if (!p) printf("p is null");
else printf("p is not null");
Code: char *p; if (*p=='\0')... |
| flexo87 is offline | |
| | #4 | |
| Algorithm Dissector Join Date: Dec 2005 Location: New Zealand
Posts: 2,434
| Quote:
All types of strings in all languages can be "empty" but only some of them can also represent the concept of being "null".
__________________ My homepage Advice: Take only as directed - If symptoms persist, please see your debugger | |
| iMalc is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OOP Question DB Access Wrapper Classes | digioz | C# Programming | 2 | 09-07-2008 04:30 PM |
| String issues | The_professor | C++ Programming | 7 | 06-12-2007 09:11 AM |
| String editor for a sentence inputted by a user - any suggestions or ideas? | the_newbug | C Programming | 4 | 03-03-2006 02:11 AM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C Programming | 3 | 03-04-2005 02:46 PM |
| lvp string... | Magma | C++ Programming | 4 | 02-27-2003 12:03 AM |