Can anyone explain me what is auto data type in C?
Thanks in advance
Printable View
Can anyone explain me what is auto data type in C?
Thanks in advance
No.
There is no auto data type in C.
There is an auto keyword. It doesn't do anything, except perhaps explicitly state that you do not want the variable it applies to to be static.
From MSDN:
Quote:
Originally Posted by http://msdn.microsoft.com/en-us/library/6k3ybftz(VS.80).aspx
I've often wondered why they even have an auto keyword? Are there ANY circumstances when you'd actually need to use it?
Well, C++ is going to use auto for variables whose type is automatically determined from the initialization:
In C it probably wouldn't make much sense, since you won't have types which are mind-bogglingly complicated. So it's just a historic relict?Code:auto i = function_returning_enormously_complicated_templated_object();
> So it's just a historic relict?
Or a futuristic relict :)
I once used a compiler that for whatever freaking reason did not automatically assume all locals are auto. So for all of the folks who wonder how come people are always spouting off about the standards for both C and C++, its little things like this that are where it all begins. I would hardly consider this a desireable behavior for a compiler to demonstrate.