Empty string: Difference between revisions
Content added Content deleted
(Added AutoHotkey examples) |
|||
Line 11: | Line 11: | ||
[[Category:String manipulation]] |
[[Category:String manipulation]] |
||
=={{header|AutoHotkey}}== |
|||
AutoHotkey has both "Traditional" or literal text, and "Expression" mode. |
|||
This code demonstrates the task using both methods. |
|||
<lang AutoHotkey>;; Traditional |
|||
; Assign an empty string: |
|||
var = |
|||
; Check that a string is empty: |
|||
If var = |
|||
MsgBox the var is empty |
|||
; Check that a string is not empty |
|||
If var != |
|||
Msgbox the var is not empty |
|||
;; Expression mode: |
|||
; Assign an empty string: |
|||
var := "" |
|||
; Check that a string is empty: |
|||
If (var = "") |
|||
MsgBox the var is empty |
|||
; Check that a string is not empty |
|||
If (var != "") |
|||
Msgbox the var is not empty</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
In C the strings are <code>char</code> pointers. A string terminates with the null char (U+0000, <code>'\0'</code>), which is not considered part of the string. Thus an empty string is <code>"\0"</code>, while a null string is a null pointer which points to nothing. |
In C the strings are <code>char</code> pointers. A string terminates with the null char (U+0000, <code>'\0'</code>), which is not considered part of the string. Thus an empty string is <code>"\0"</code>, while a null string is a null pointer which points to nothing. |