We came across this in our code
int column, row, index; column = index = row = 0;
so I did a search and found this topic, only the last variable gets initialized
Updated link
https://stackoverflow.com/questions/6838408/how-can-i-declare-and-define-multiple-variables-in-one-line-using-c
I can't access that link, but why would this not initialize all three variables? Seems to work just fine: https://godbolt.org/z/T88e61s6h
Updated link, maybe there are compiler differences but I'd hope not...
Log in to post a comment.
We came across this in our code
int column, row, index;
column = index = row = 0;
so I did a search and found this topic, only the last variable gets initialized
Updated link
https://stackoverflow.com/questions/6838408/how-can-i-declare-and-define-multiple-variables-in-one-line-using-c
Last edit: Steve Albright 2024-05-22
I can't access that link, but why would this not initialize all three variables?
Seems to work just fine: https://godbolt.org/z/T88e61s6h
Updated link, maybe there are compiler differences but I'd hope not...