Hacker News new | past | comments | ask | show | jobs | submit login




And what does it mean there? (automatic storage duration)


It means it lives on the stack, so it "exists" until the function returns.



Do you mean automatic type deduction?

Edit : I know it’s also storage specifier but it also does type deduction here, hope I’m not confused with the terminology


It doesn't do type deduction there.

In original C you could declare variables without a type, and these variables with auto have no type.

So this "auto" is essentially saying "this variable without a type uses automatic storage". That's a completely different language feature from "deduce the type of this variable".


A variable without a type is 'int' so ```auto xx;``` means an int on the function local variable stack.


Thanks.


No, it doesn't do type deduction. Without specifying the type, it assumes a type of int. Everything in C revolves around ints.


here it means automatic storage duration




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: