Learn from Yin Cheng and C + + 008

Source: Internet
Author: User
Tags logical operators sprintf

Comma operator
Lowest priority level
The value of the comma operator is the last value
int a= (UP);
Execution result is 2
The comma operator is executed for each statement, and the direction of execution is left to right

Trinocular operator
Expression 1-expression 2: Expression 3

There are only 0 and 0 differences in C language.

The trinocular operator takes the maximum value, the minimum value

Data mining

Relational operators are left-to-right in the direction of operation
If the 3>2>1 judge the result is 0

Same constant string that stores the same address

logical operators
Logical "and" Operators &&
Logical "or" operator | |
Logical "not" operator

"and" operator short-circuit effect, a condition does not conform to continue to carry out in the future
"or" operator short-circuit effect, a condition conforming to the following will not be performed

CGI output information on the server

#include <stdio.h>
#include <stdlib.h>

void Main ()
{
printf ("content-type:text/html\n\n"); Declaring the HTML language
printf ("Hello");


}

Input and output of data
Printf
Output to file, command line, Web page


sprintf input to String

printf ("\n%10d", 10); Width is 10, default right is aligned,-left alignment right blank


. N Intercept strings and decimals, only from the left

32-bit%d and%ld int and long equivalents


Char str[100]= "Calc"; String


#include <stdio.h>
#include <string.h>

void Main ()
{
Char str[10] = "task";
Char newstr[10] = "list123";
Char strall[100] = {0};
sprintf (Strall, "%s%.4s", str, NEWSTR); string addition
System (Strall);
System ("pause");

}

void Main ()
{
Char str[10] = "task";
Char newstr[10] = "123list123";
Char strall[100] = {0};
sprintf (Strall, "%s%.4s", str, newstr+3); Use the move of the character address to crop to the left part of the string
System (Strall);
System ("pause");

}

%.10f. 10 decimal points reserved 10 digits

Index
E format character

%e Index output

%g automatically chooses to output real numbers in F or e format, depending on the size of the values, and automatically chooses a smaller width


%HD, short integer, 16-bit storage, 2^16-1,short range
%hu

%lu, long, 32-bit system with%lu,%ld equivalent to%u,%d
%ld

Store ID number, mobile number, long long%llu,%lld

%o% #o marked octal when the output of the # number is added

General octal, Hex plus #

%d,%o,%u cannot be capitalized
Except for X, E, and G, all other lowercase letters
Letter output can be case-%o exception

printf does not complete data type conversions and requires exact matching
\ escape Character


%.*f * To change the decimal position

Learn from Yin Cheng and C + + 008

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.