O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

String Processing

Because the input stream is usually terminated by pressing the Enter key—telling the operating system that you have finished typing for the time being—it makes sense to collect all the characters that might be in that stream in one go if at all possible. The gets function allows you to do this.

The generic definition for gets is as follows:

char * gets ( char * <string variable> );

You have not yet read about pointers, and it is quite an advanced topic that bears some explanation once you’ve gained more experience with C in general. In the case of the char * pointer, however, it does actually refer to something that you have seen before—an array of characters, otherwise known as a string.

String input and output are performed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required