GIDNetwork > Things to Avoid in C/C++ -- scanf / string, Part 7
Register
« Things to Avoid in C/C++ -- scanf / character, Part 6 Things to Avoid in C/C++ -- scanf / number, Part 8 »

Things to Avoid in C/C++ -- scanf / string, Part 7

by: WaltP - Sep 27, 2005

scanf() / Reading a string

There is only one thing I really need to say about using scanf() to read a character string:

Read this about gets() and replace with scanf("%s", ...).

scanf() and gets() have the exact same problem with memory overrun. You can easily read in more characters than your char* can hold. And of course, scanf() has The Steps, too.

The solutions are the same.

'Nuff said.

Coming next, scanf() / Reading numbers.

I'll be baaack...

Would you like to comment? This story has been viewed 97,894 times.
« Things to Avoid in C/C++ -- scanf / character, Part 6 Things to Avoid in C/C++ -- scanf / number, Part 8 »

__top__

Copyright © GIDNetwork™ 2001 - 2017

Another website by J de Silva

Page generated in : 0.01866 sec.