cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
unexpected output for very simple code
unexpected output for very simple code
Jun 2, 2016 at 6:04am UTC
Mikenuaimi
(5)
I expect to get empty or null result but I get random special characters
like �@ or *�y�... what is that mean?. I am using eclipse
1
2
3
4
5
6
7
#include <stdio.h>
int
main () {
char
str[10]; puts (str);
return
0; }
Jun 2, 2016 at 6:28am UTC
TheIdeasMan
(6817)
Hi,
str
is not initialised so it contains garbage, and that is what output. Garbage in, garbage out.
So the golden rule is to always initialise your variables :+)
Cheers
Topic archived. No new replies allowed.