Timeline for Problem set 1 Mario variable issue
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 1, 2020 at 21:35 | comment | added | Rayray94 | Alright will do, thank you. | |
May 1, 2020 at 21:34 | vote | accept | Rayray94 | ||
May 1, 2020 at 21:07 | comment | added | Cliff B | Oh, what happens if you enter an invalid number ? Think about what it should do and what it does do. | |
May 1, 2020 at 21:03 | comment | added | Cliff B | OK, so the scope problem is resolved and the program compiles. That solves this problem. If you are having more issues, they warrant a new question. One problem, one question. Also, please undo the last edit so that others that read this don't get confused. thanks. | |
May 1, 2020 at 20:30 | comment | added | Rayray94 | I updated it, it showed that there was no error so I proceeded to the next step. It doesn't look like it recognized a scope issue. | |
May 1, 2020 at 20:22 | comment | added | Cliff B | Still the same scope problem. 'h' is declared inside a pair of curly braces. It ceases to exist after that closing curly brace. You need to declare h before the do loop, just like you did with n. | |
May 1, 2020 at 19:59 | comment | added | Rayray94 | I've updated with the new results. | |
May 1, 2020 at 19:38 | comment | added | Rayray94 | Ok I'll try that, thank you. | |
May 1, 2020 at 19:24 | comment | added | Cliff B |
That's exactly what I expected. A shadow variable occurs when you redeclare a variable. My bet is that when you try to use the variable, you're also using the int declaration with it. So, remove the later int . If this isn't it, you will need to post the current code so I can see exactly what you're doing. Also, search the forum for "shadow variable" for more info and understanding.
|
|
May 1, 2020 at 19:11 | comment | added | Rayray94 | But I don't know how to fix it. It's saying declaration shadows a local variable now when I type make mario. | |
May 1, 2020 at 18:57 | comment | added | Cliff B | No, it's still a scope issue. | |
May 1, 2020 at 18:29 | comment | added | Rayray94 | I had int h before and it said the same thing. I know the image says int n but that is because I was in the process of changing h's to n's. It seems like there is some other problem with it. | |
Apr 29, 2020 at 8:11 | history | answered | Cliff B | CC BY-SA 4.0 |