unexpected output for very simple code

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;
}
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.