Characters and strings
Characters according to%d, print asccii
Characters Press%c to print the characters themselves
' 0 ' 0 ' + ' difference:
Char ch3=0; The equals sign is automatically converted to the character that corresponds to the ASCCII value. That is, null or
C string cannot be added directly
String%s
sprintf printing to a string
#include <stdio.h>
#include <stdlib.h>
void Main1 ()
{
char ch = ' A ';
Putchar (CH);
printf ("%c", ' A ');
GetChar ();
}
void Main2 ()
{
char ch = ' A ';
wchar_t WCH = L '; Wide character ' A ' in order to be compatible with extended wide characters, typically 4 bytes, but assigned to CH for 1 bytes
System ("color 4f");
System ("title Liu Mitong");
System ("pause");
The string/0 ends, equal to each character, and the tail is added ' s '.
}
void Main ()
{
char ch = getchar ();
if (ch >= ' A ' &&ch <= ' Z ')
{
CH = ch + 32;
}
Putchar (CH);
System ("pause");
}
Create a variable symbol table
Real numbers do not seek remainder
Data type conversions
printf ("%d", (int) 12.1);
printf ("%f", (float) 10);
printf is not automatically converted, int converts integers
Automatic type conversion of operations between different data types
Forcing type conversions
float a1=10.8;
float a2=10.3;
int num= (int) a1+a2;
int num2= (int) (A1+A2);
Large data types to small conversion accuracy will be lost
printf ("%.2f", db); Show only two digits after the decimal point
Memory principles for data type conversions
Data loss occurs with big data int to Char
unsigned int cannot be assigned a negative number
Being able to compile does not mean that the result is correct
scanf%LF corresponds to double
Learn from Yin Cheng and C + + 006