from bottom to top#include //define a function to sumintSumintNUM1,intnum2) { returnnum1+num2;}//define a function to calculate the averageintAverageintNUM1,intnum2) { returnSUM (num1,num2)/2;}intMainintargcConst Char*argv[]{intA =Ten; intb = -; intrs = average (Ten, -); printf ("RS=%d\n ", RS);return 0 ;}Six function declaration1. function declaration: Just copy the function head to the front of the function that called it2. Function: Tell the compiler that the function already exists.N
elementSwapping elements for idx1 and IDX2 positions-(void) Exchangeobjectatindex: (Nsuinteger) idx1 Withobjectatindex: (Nsuinteger) idx2; Nsmutablearray *arr5 =[nsmutablearray arraywithobjects:@1,@2,@3,@4,@5, nil]; The elements of the array element//subscript 0 can be exchanged with the element of subscript four [Arr5 exchangeobjectatindex:0 withobjectatindex:4]; NSLog (@ "%@", ARR5);-----------------Nsmutablearray Error usageNsmutablearray *array = @[@ "Bob"
.traverse the key in the dictionaryNSLog (@"Traverse dictionary \ n");//Fast Traversal for(IDKeyinchdictionary5) {NSLog (@"%@", key);}//iterate through the value in the dictionary for(IDKeyinchdictionary5) {NSLog (@"%@", [Dictionary5 Valueforkey:key]);}//12.Variable DictionariesNsmutabledictionary * Dictionary2 =[Nsmutabledictionary dictionary];//13.Setobject:forkey: Add value and key and replace the value if key exists[Dictionary2 SetValue:@"Itheima"Forkey:@" First"]; [Dictionary2 SetValue:@"It
definition of a functionPurpose: Encapsulates a common function that implements the invocation of a function.Format:return value type function name (formal argument list) {function Body }function calls and formal parameters of functions, arguments#include Note: 1. The number of arguments must be equal to the number of formal parameters2. Variables within the function body that cannot be defined as parameters3. The function does not define the same variables as the parameters4. If the base data
braces {}}Switch statement1> syntax structureSwitch (value){Case value 1;Statement 1;Break Break: Exit the entire switch statementIf there is no break behind the case, the statements in all the following will be executed until Bresk is encounteredCase value 2;Statement 2;BreakDefault:Statement 3;Break}2>switch Statement Usage Note* Also on the scope of the problem, if you define a new variable in the case statement, will cause this variable scope confusion, system error.Workaround: Define a new
} Oneprintf"%d", *p[1]) ; A return 0; -}int *p[3] There are pointers.2. The difference between pointer function and function pointerA pointer function is a function whose return value is a pointer. In fact, there is no pointer function to say that only the return value is a function of a pointer or a function that is a pointer to a parameter.A function pointer is a pointer to a specific function. It is very useful in programming, can significantly reduce the amount of code and optimize th
1. IdentifiersIn the C language, symbolic constants, variables, arrays, functions, etc. all require a certain name, and we make this name an identifier.2. The principle of naming identifiersNaming rules:1. Can only be composed of letters, numbers, underscores or dollar signs ($)2. Cannot start with a number3. Cannot duplicate the keyword4. Strictly case-sensitiveNaming conventions:1. Identifier naming specificationNaming conventions:Make a meaningful
[]={233,45,6};(2) Partial initialization at the same time as definedAn array of length 3 is defined, the array name is A1, and the elements of the array are assignedElement 1 of 1thElement 23 of 2ndElement 0 of 3rd?int a1[3]={1,23}; The first of these methodsDefines an array of length 10, the array name is A4,[3] indicates that the subscript 3 element assigns an initial value of 23[8] indicates that the subscript 8 element assigns an initial value of 34int a4[10]={[3]=23,[8]=34};2) define the ar
Windows programmers use VS or WinDbg to debug quite familiar, go to Linux under, to do program writing, debugging, often very painful (or not used to it). Now can find a variety of IDE or editing software quite a lot, I tried to have eclipse+cdt+gdb,codeblock+gdb,vi+cgdb, are not ideal, from time to time to rely on VS, has always been the complex of vs.One day, looking for gdb how to display the current process loaded dynamic library, found in visualgdb about the GDB tutorial, at this time sudde
Dark Horse programmer--c Language learning experience--bit operator-------Java training , Android training ,iOS training ,. Net Training , look forward to communicating with you! -------The bitwise operator C language provides six bitwise operators: Bitwise AND| Bitwise OR^ Bitwise XOR OR~ Take counter>> Right Shift1. Bitwise AND Operation bitwise AND operato
How to optimize C language code (programmer must Read)5, reducing the intensity of the operation can replace the original complex expression with an expression with a small operand but with the same function. as follows: (1), to find the remainder operation. A=a%8; can be changed to: a=a7Note: Bit operations can be done in only one instruction cycle, while most of the C
flexibility and makes the program code more concise and efficient. Pointer variables can appear in an expression, set int x,y,*px=x; pointer variable px to an integer x, then *px can appear anywhere x can appear. For example: y=*px+5; /* means adding 5 to the contents of X and assigning it to y*/y=++*px; /*PX content plus 1 is assigned to Y,++*PX equivalent to + + (*PX) */y=*px++; /* equivalent to Y=*PX; px++*/main() { int a,b; int *pointer_1, *pointer_2; a=+; b=ten; pointer_1
This article describes the implementation of C language programmer ancient History. Share to everyone for your reference. Specifically as follows:
I've seen a jquery programmer ancient history page before, feel quite creative, their free use of C language also wrote a, the basic is the generation of random numbers, no
Programmer --- C language details 24 (segment error, type improvement, sizeof #39; A #39 ;)Main Content: Segment error, type improvement, sizeof 'A'
# Include
Int main () {union test {char a [10]; int B;} u; int * p = (int *) (u. a [1]); // No Bus Error Caused * p = 17; printf ("% d \ n", * p); # if 0 int * q = 0; // cause a segment error. You can see the segment error when running in linux. * q
The definition of a function pointer:Header file: Function.hThe header defines the interface, defines the template method in the actual source file//The subsequent calling class only needs to implement a callback that overrides the Before,process,after method to implement the template method/*extern can be placed before a variable or function, To indicate the definition of a variable or function in another file, prompting the compiler to find its definition in other modules when it encounters th
instance 0x100114f10. This method is not implemented or is not available. check whether this method is implemented.-(Void) Click{If _ delegate implements onclick: method, this method is called.If ([_ delegate respondstoselector: @ selector (onclick :)]){When the button is clicked, the listener should be notified, and the listener should be notified of which button is clicked.[_ Delegate onclick: Self];}Else{Nslog (@ "The Listener does not implement onclick: Method ");}}@ End
Block as proxy call
Public Static voidMain (string[] args) { stringA ="A"; stringb = A = ="A"?"B1":"B2"+"END"; stringc = (A = ="A"?"C1":"C2") +"END"; Console.WriteLine (b); //B1Console.WriteLine (c);//C1endConsole.readkey (); }It is important to note that some of the scenes are bracketed, otherwise the contents of the following are treated as part of the trinocular operator.3, Is/asThe IS operator is used to check whether an object is compatible with
keyword"1. Break Statement usage:Can be used in the loop, the expression jumps out of the loop, the loop ends, can be used in the switch inside, the end of the statement, the subsequent do not execute;If there is no break then there will be case penetrating;In a multilayer loop, break just jumps out of a layer of loops, and the outer layers are executed;"Continue keyword"1. Continue statement:End this cycle and continue the next cycleIt is used in for,while and other loops, often used together
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.