Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto keyword

Status
Not open for further replies.

cat5ive

MIS
Joined
Dec 3, 2004
Messages
184
Location
US
Hi,

Code:
void func1(int y)
{
   auto int count;
}
what's the keyword auto for? The book only mention that we can include it with automatic variable but did not tell what's the advantage of including it? And it seem that I still need to explicitly initialize variable count(so it doesn't contain garbage). So may be it should be something like this instead?
Code:
void func1(int y)
{
   auto int count=0;
}

Can someone please explain to me?
 
> what's the keyword auto for?
IIRC, auto was only used in a compiler symbol table. Other than that the only other possible purpose for auto is to format your declarations so that they match up vertically in the presence of other qualifiers:
Code:
const  int  a;
auto   long b;
static char c;
Semantically, it's worthless because anywhere that auto would be legal already defaults to it. So it would be redundant.
 
Status
Not open for further replies.

Similar threads

  • Locked
  • Question Question
Replies
1
Views
131
  • Locked
  • Question Question
Replies
0
Views
128

Part and Inventory Search

Sponsor

Back
Top