What is string literal? Null character '\0'. What about slash zero. (\0)? How its work ? Tell me info. About that. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

What is string literal? Null character '\0'. What about slash zero. (\0)? How its work ? Tell me info. About that.

13th Nov 2020, 3:32 PM
SARVESH ASHOK DEVRUKHAKAR
SARVESH ASHOK DEVRUKHAKAR - avatar
7 Respostas
+ 1
As Davide says, \0 on strings means the end of array. For pointers, NULL is for no indicate adress of memory of pointer type (see pointers on c course), unusue. When you assign like: int *ptr=NULL; printf("%x\n",ptr);//outputs 0, because *ptr (the memory pointed by ptr) is NULL, (dont have any adrres). *ptr=5; prinf("%x\n",ptr);//outputs something like 234fab82 (an hexadimal number wich is a adrres memory where the machine store the value of 5) int a=5; ptr=&a; printf("%x\n",ptr);//outputs the adrres of a, wich is type int, and store the value 5; printf("%d\n",*ptr);//outputs the value of a, wich adrres is pointed by ptr, and her value is acceded by the * operator. Good luck. Sory for bad english.
13th Nov 2020, 9:33 PM
MICAEL MIRANDA
MICAEL MIRANDA - avatar
+ 6
Read this for string literal: https://stackoverflow.com/questions/50125126/what-is-a-literal-string-char-array-in-c \0 is the character that tell where the string ends. If I create the array: char array[2]; array[0] = "a"; array[1] = "b"; And then I do: printf("%s", array); The output will be something like that: abgj?hkf)&#-:dh.... Until a random \0 character is found in the memory
13th Nov 2020, 4:17 PM
Davide
Davide - avatar
+ 2
\n is what is know as an escape sequence character. And what is does is that it goes to a new line when you are writing something to the console. Just think of hitting the enter key on your computer when you type. Hope this helps.
13th Nov 2020, 3:44 PM
pNK
pNK - avatar
+ 2
#$ÅŖPĒŘŠ.ƅ.Đ. I don't really know much C programming but I found it on stackoverflow hope it helps https://stackoverflow.com/questions/14461695/what-does-0-stand-for/14461711#:~:text=In%20C%2C%20%5C0%20denotes%20a%20character%20with%20value%20zero.&text=The%20'%5C0'%20inside%20character,in%20Objective%20C%20is%20identical.
13th Nov 2020, 3:57 PM
pNK
pNK - avatar
+ 1
I am sorry. It's my mistake . I know about slash N (\n). I want answer about slash zero (\0).
13th Nov 2020, 3:51 PM
SARVESH ASHOK DEVRUKHAKAR
SARVESH ASHOK DEVRUKHAKAR - avatar
+ 1
Ok.
13th Nov 2020, 3:58 PM
SARVESH ASHOK DEVRUKHAKAR
SARVESH ASHOK DEVRUKHAKAR - avatar
+ 1
MICAEL MIRANDA, how's your English. I don't care. But now I understood what you going says. Thanks.
13th Nov 2020, 11:59 PM
SARVESH ASHOK DEVRUKHAKAR
SARVESH ASHOK DEVRUKHAKAR - avatar