12
I read that global variables are those that we declare outside of all functions using #define
and this way they could be used by all functions of a program. However, I was informed that the variables declared in main
are global. I’m pretty sure this is false, since the variables we declare in main can only be used by other functions if we pass it by parameter.
That’s not what was asked but the biggest problem of the answer is that a value created with
#define
takes place in memory, like any data. Another problem is calling variable constant.– Maniero
I looked in the Mazano book, actually the compiler understands so. I’ll take another look, but that’s how I learned.
– Giovanni Cruz
Can you quote the passage that says this? Put context. Either you got it wrong or the book is bad.
– Maniero
Maybe I misunderstood, but Manzano is not bad not, if he was bad not kkk I have class with him until! " A constant in C language can be simulated by using the const command, which creates a variable in memory and sets a fixed (immutable) value which cannot be modified until the execution of the program is complete."
– Giovanni Cruz
I just tidied up there, but the book was right, I ended up reversing the #define and the const.
– Giovanni Cruz
But the answer is still wrong and still does not answer what was asked. If the book says it, I say it’s bad.
– Maniero
I don’t know, I don’t have a class with him, I didn’t read his book, I didn’t see the quote. So I can’t talk. But if I had that information, I could evaluate it since I have experience with it. Who has initial knowledge only, can not assess what is good or not, for that person the initial source she had is always good. It might be the best thing you could have access to or it might be something that’s teaching you all wrong.
– Maniero