C Language Review 2

Source: Internet
Author: User
Tags bitwise

01-while01break jump out of the loop continue out of this cycle, into the next cycle 02-while02 calculate 1+2+3+...+n andWhat is the role of q1:unsigned? It's not going to work in general calculations .A. Function declarations and declarations of defined functions can be declared arbitrarily at any place, as long as they are written before the call. #include <stdio.h>

int main (int argc, const char * argv[]) {
void Test ();
void Test ();
void Test ();
void Test ();
void Test ();
Test ();

return 0;
}

void Test ()
{
printf ("test\n");
The link error B will appear only if you declare a function that is not implemented. #include # include is equivalent to copying the content in the ingest file # include <stdio.h>

int main (int argc, const char * argv[]) {
#include "T.txt"


return 0;
C. Multi-file project development use the. h header file and the. C source code to use, let the main source # include header file, get the function declaration in the same directory in the source file function does not conflict, otherwise the link error d.printfprintf returns the length of the string, including the escape character E. Binary int number = 0b1010; output format without binary octal int number2 = 07613;
printf ("number2 =%o\n", number2); hexadecimal int number3 = 0X9FEA3;
printf ("Number3 =%x\n", Number3); You can use a different format output, the compiler will automatically convert the binary F. Type specifier (can only be decorated int) Short int: = short 2 bytes Long Int:long 8 bytes = long output placeholder%ldsigned int: = signed default Signed bit unsigned int: = unsigned remove the sign bit to hold the value long long int:= long long in 64-bit system or 8 bytes, with long no difference output placeholder%lld int s = sizeof ( long long int);
printf ("s =%d\n", s); G. Bitwise operation 1.& Bitwise AND 2.| Bitwise OR 3.^ bitwise OR the same type of bitwise operation is in accordance with the Exchange Law 4.~ the counter-attention in the 64-bit system, int accounted for 8 bytes, and in the form of complement, is in this condition to take the inverse 5.<<n left shift can be in accordance with the actual value of the displacement, the highest value of elimination, And the sign bit does not change the equivalent of multiplying by 2 of the n-th square 6.>> right shift using ^ Exchange two variable value int l = 10;
int m = 20;
L = l ^ m;
m = l ^ m;
L = l ^ m;
printf ("L =%d, M =%d\n", L, M); Computes the parity common method a%2==0?printf ("Even!\n") with the bitwise operator:P rintf ("Odd \ n");Bitwise operation A&AMP;1?PRINTF ("Odd!\n"):p rintf ("even \ n"); Writing a binary output function H.char character occupies 3 bytes, cannot use char I. Array special declaration, definition method int ages[5] = {[2] = 4, [4] = 1}; int count = 5;int Ages[count]; Error: int D[count] = {1,2,3,4,5}; The array size must use a constant array as a function parameter when the array length array is omitted as a function parameter is a pointer passed as an array of parameters when using sizeof, the array as a pointer exists, Length is 8 bytes

C Language Review 2

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.