Can anyone explain me what is auto data type in C?
Thanks in advance
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:
Originally Posted by http://msdn.microsoft.com/en-us/library/6k3ybftz(VS.80).aspx
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
I've often wondered why they even have an auto keyword? Are there ANY circumstances when you'd actually need to use it?
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
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();
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
> 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.