+ 3

Printing an empty string in c

Why does this program print those symbols? #include <stdio.h> int main() { char txt[20]; puts(txt); return 0; } Output: @@

29th Oct 2019, 11:47 AM
Prasun Adhikari
Prasun Adhikari - avatar
1 Odpowiedź
+ 6
Prasun Adhikari this happens because when you try to display txt[] then in the memory it was having some values(in your case @@) on your device. Such type of values are known as GARBAGE VALUES So it is essential to initialise the variables you declare otherwise they contain some garbage values like this
29th Oct 2019, 12:14 PM
Arsenic
Arsenic - avatar