What the hell does auto do? Yep, I didn't search google, I want the info direct from a C guru who might be loitering :)
I was happily going to use auto as an identifier then my trusty IDE highlighted it. I've never seen it used anywhere before.
Printable View
What the hell does auto do? Yep, I didn't search google, I want the info direct from a C guru who might be loitering :)
I was happily going to use auto as an identifier then my trusty IDE highlighted it. I've never seen it used anywhere before.
It's the default keyword used for variables. The counterpart to static. If you have:
it's the same as having:Code:int num;
Your IDE should also be able to tell you that.Code:auto int num;
EDIT: Regarding its usefulness see: http://www.eskimo.com/~scs/C-faq/q1.12.html
Hmm. Can we expect to see it removed from the language in the future?Quote:
Originally Posted by itsme86
No. They like to keep things for backwards compatability. Feel free to refer to this post in the future and say I'm wrong, but I won't hold my breath. Want proof? getsQuote:
Originally Posted by ahluka
Quzah.
Good point :DQuote:
Originally Posted by quzah
But well, I know people that want strcpy() to be removed because strncpy() is sooooo much safer :rolleyes:
Yeah, but strcpy() is only unsafe when used on an untrusted source string. gets() is never safe.
Okay, I guess there's the extremely rare circumstance such as head -c 50 some_file | my_program_that_uses_gets_with_a_buffer_bigger_tha n_50 but come on...
strcpy() is perfectly safe as long as you know what you're doing with it.
You do get irony, do you?
Actually the auto keyword is good for declaring vehicles:
See question 1.8 of http://www.plethora.net/~seebs/faqs/...html#section-1
:p
One word: LOL
> because strncpy() is sooooo much safer
True, but the disaster normally strikes on the next line when you realise that strncpy() doesn't always copy the \0 at the end of the string, so something which expects to find a \0 is out of luck.