4 ms·
Um, why wouldn't it be correct to call any/all of thoes examples a variable?
by grayhatter 6y ago
Um, why wouldn't it be correct to call any/all of thoes examples a variable?
- saagarjha 6y agoThey’re not variables until they’ve been specified a type, which is at the point you first assign to the memory in a typed fashion I believe. It’s significantly more pedantic than the first line in an introductory text will go into, though ;)
- grayhatter 6y agoNah, that's wrong. A variable doesn't need a type. Case in point; void.
- saagarjha 6y agoI'm not sure what you mean, could you explain a bit more?
- icedchai 6y agoAll variables have types in C. You can't declare a "void" variable. You can declare a void function. Try assigning it to a variable. You can't. void pointers (void*) are a different story.
- eru 6y agoSo just the opposite of what the comment you replied to suggested: 'void' is a type, but in C values of the type void are not first class. Ie a function can return a value of type void, but you can't assign it to a variable.
- eru 6y agoAre you saying void is not a type?