Hi guys,
Just a quick question really regarding using strings in C.
I know that a very good way in to capture and display a string in C is to use the gets() function. I know this used to be all the rage in C but now its frowned upon and some compilers now pick upon this as a warning error.
For example if you were to write something like
[CODE="c"]printf("\nTown name: ");
gets(address.to wn, 25, stdin);
address.town[strlen(address. town) -1] = '\0';
puts(address.to wn);[/CODE]
some compilers now pick this up as bad practice. What bugs me is what alternative function could you now use to grab and display a string in C is gets() is so bad?
Thanks
Just a quick question really regarding using strings in C.
I know that a very good way in to capture and display a string in C is to use the gets() function. I know this used to be all the rage in C but now its frowned upon and some compilers now pick upon this as a warning error.
For example if you were to write something like
[CODE="c"]printf("\nTown name: ");
gets(address.to wn, 25, stdin);
address.town[strlen(address. town) -1] = '\0';
puts(address.to wn);[/CODE]
some compilers now pick this up as bad practice. What bugs me is what alternative function could you now use to grab and display a string in C is gets() is so bad?
Thanks
Comment