Guest User

Untitled

a guest
Aug 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. Why we must initialize a variable before using it? [closed]
  2. int count = 0;
  3.  
  4. while(count < 500)
  5. {
  6. doFunction();
  7. count ++;
  8. }
  9.  
  10. ...
  11.  
  12.  
  13. void doFunction() {
  14.  
  15. count = sizeof(someString);
  16. print(count);
  17.  
  18. }
  19.  
  20. int i = 0;
  21. int j = foo();
  22.  
  23. struct Foo { int i; int j; }
  24.  
  25. struct Foo f = {0};
  26.  
  27. int i ; // uninitialised variable
  28.  
  29. i = some_function() ; // variable is "used" in left of assignment expression.
  30. some_other_function( i ) ; // value of variable is used
Add Comment
Please, Sign In to add comment