It is now recommended that fgets() be used in place of the gets() function that has been marked as deprecated. So the example on page 110/111 of “C Programming in easy steps” should appear as:

 

#include <stdio.h>

 

int main()

{

char str[51] ;

 

printf( “\nEnter up to 50 characters with spaces:\n” ) ;

fgets( str, sizeof( str ), stdin);

 

printf( “fgets() read: ” ) ;

puts( str ) ;

 

printf( “\nEnter up to 50 characters with spaces:\n” ) ;

scanf( “%s”, str ) ;

printf( “scanf() read: %s\n” , str ) ;

 

return 0 ;

 

}

Leave a Reply

We are sorry to let you go...

Would you mind giving us your feedback or reason of cancelling the subscription?

 

"*" indicates required fields

Hidden
Hidden
Hidden
Reason For Cancellation*
Hidden