Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What do %ld, %d and %U in c mean?
What do %ld, %d and %U in c mean?
These are format symbols used by C language to format input and output. Among them, %U is misspelled, but it is actually% u.

Print format functions include printf, fprintf, sprintf, etc.

The formatted input functions are scanf, fscanf, sscanf, etc.

This kind of function has a parameter format string (format_str) when inputting and outputting, and introduces the format of the input and output string. When you need to input and output variable values, you need to use the corresponding format characters.

The three formats mentioned in the title correspond to each other:

%ld corresponds to long, which means long integer.

%d corresponds to int type, which means integer type.

%u corresponds to unsigned int, that is, unsigned integer.

In addition, there are the following common types.

%hd corresponds to short type, that is, short integer.

%hu corresponds to unsigned short integer, that is, unsigned short integer.

%f corresponds to floating-point type, that is, single-precision floating-point type.

%lf corresponds to a double-precision type, which is a double-precision floating-point type.

%c corresponds to char type, that is, character type.

%s corresponds to char * type, that is, character pointer/character array (both can be called strings).

%x corresponds to int type, but the input and output are in 16.

%lx corresponds to long, which is also in the form of 16.

Here is a simple example:

# Contains? & ltstdio.h & gt

int? Master ()

{

int? Me;

Dragon? l;

Not signed? int? u; //Define three different types of variables.

Scanf("%d%ld%u ",&me&&; u); //Format and enter three variables, each corresponding to its own type.

Printf ("me? =? %d\n ",I);

printf("l? =? %ld\n ",l);

printf("u? =? %u\n ",u); //Print the values of three variables in the format.

Return? 0;

} If you enter 1 2 3,

Will output

Me? =? 1

l? =? 2

u? =? three