Sams Teach Yourself C in 21 Days

(singke) #1
to the format of the corresponding specifier in the format string. For each argument,
there must be a conversion specifier. Table 7.2 lists the most commonly needed conver-
sion specifiers.
Example 1
int x, y, z;
scanf( “%d %d %d”, &x, &y, &z);
Example 2
#include <stdio.h>
int main( void )
{
float y;
int x;
puts( “Enter a float, then an int” );
scanf( “%f %d”, &y, &x);
printf( “\nYou entered %f and %d “, y, x );
return 0;
}

Using Trigraph Sequences ..................................................................................


You have now learned the basics of reading and writing information using functions such
asprintf()andscanf().There is one additional topic that will be covered in today’s
lesson. This is not about reading and writing information, rather it is about special
sequences of characters in your source file that will be interpreted to mean something
else. These special sequences are called trigraph sequences.

162 Day 7

,


,


You will most likely never use trigraph sequences. It is included here in case
you inadvertently use a trigraph sequence in your code and find that it
automatically gets converted as described below.

Note


Trigraph sequences are similar to the escape sequences you learned about earlier. The
biggest difference is that trigraph sequences are interpreted at the time the compiler looks
at your source code. Anywhere in your source file that a trigraph sequence is found, it
will be converted.
Trigraph sequences starts with two question marks (??). Table 7.3 lists the trigraph
sequences listed in the ANSI standard. Per the standards, no other trigraph sequences
should exist.

11 448201x-CH07 8/13/02 11:20 AM Page 162

Free download pdf