4. What is the purpose of static? (Please specify at least two types)
1. restrict the scope of Variables
2. Set the storage domain of the Variable
7. What is the difference between reference and pointer?
1) The reference must be initialized and the pointer is not required.
2) The reference cannot be changed after initialization. the pointer can change the object.
2) There is no reference pointing to a null value, but there is a pointer pointing to a null value.
8. Describe the basic features of the Real-Time System
Complete specific tasks within a specific period of time, real-time and Reliability
9. Are global variables and local variables different in memory? If so, what is the difference?
Global variables are stored in the static database, and local variables are stored in the stack.
10. What is a balanced binary tree?
Both left and right Subtrees are balanced binary trees, and the absolute value of the depth difference between left and right Subtrees is not greater than 1.
11. What causes stack overflow?
No garbage collection resources
12. What functions cannot be declared as virtual functions?
Constructor
13. What is the time complexity of the bubble sort algorithm?
O (N ^ 2)
14. Write the if statement for comparing float X with "zero value.
If (x> 0.000001 & x <-0.000001)
16. What network protocol does the Internet use? What is the main hierarchy of the protocol?
TCP/IP application layer/Transport Layer/Network Layer/data link layer/Physical Layer
17. What protocol does the physical and IP address translation use for the Internet?
ARP (Address Resolution Protocol) (Address Resolution proposal)
18. What are the IP address encoding components?
An IP address consists of a network number and a host number. However, it can only be distinguished from the subnet mask after bitwise AND top.
Which are network bits and which are host bits.
2. the user inputs the M and N values. The number of sequential loops starts from 1 to n. This value is output on each count to m until all are output. Write
C program.
Cyclic linked list, with the remainder operation
3. The parameter types that cannot be switched () are:
The Switch Parameter cannot be of the actual type.
Think
1. Can a local variable be renamed with a global variable?
A: Yes. Global blocking will be performed in some cases. To use global variables, you must use "::"
A local variable can have the same name as a global variable. When this variable is referenced in a function, a local variable with the same name is used instead
Global variables are used. For some compilers, multiple local variables with the same name can be defined in the same function,
For example, a local variable with the same name is defined in both loops, and the scope of the local variable is in that loop.
Body
2. How to reference a defined global variable?
Answer: extern
You can reference a header file or use the extern keyword.
The global configuration change stated in the header file. If you write the change into an error, an error will be reported during compilation. If you use ex
If you make the same mistake when referencing the tern method, no error will be reported during compilation, but an error will be reported during connection.
3. Can global variables be defined in header files that can be contained by multiple. c files? Why?
A: Yes. You can declare global variables with the same name in static form in different C files.
You can declare global variables with the same name in different C files, provided that only one of them can be assigned to this variable in the C file.
Value. At this time, the connection will not fail.
4. What is the problem with the for (; 1;) statement? What does it mean?
A: It is the same as while (1.
5. Do ...... While and while ...... What is the difference between do and do?
A: The previous cycle is used to judge again, and the last one is recycled later.
6. Write the output content of the following code.
# Include <stdio. h>
Main ()
{
Int A, B, C, D;
A = 10;
B = A ++;
C = ++;
D = 10 * A ++;
Printf ("B, c, d: % d, % d, % d", B, c, d );
Return 0;
}
Answer: 10, 12, 120
1. What is the difference between static global variables and common global variables? What are static local variables and common local variables?
Difference? What is the difference between a static function and a common function?
The description of global variables (external variables) is preceded by static to form a static global variable. The global variable itself
It is a static storage method, and static global variables are also a static storage method. The two are not different in storage methods.
. The difference between the two lies in that the scope of non-static global variables is the entire source program.
Non-static global variables are valid in each source file. Static global variables limit
It is valid only in the source file defining the variable. It cannot be used in other source files of the same source program.
Because the scope of static global variables is limited to one source file, they can only be shared by functions in the source file. Therefore
To avoid errors in other source files.
From the above analysis, we can see that after changing a local variable to a static variable, it changes its storage method.
Lifetime. After changing a global variable to a static variable, it changes its scope and limits its scope of use.
Static functions have different scopes than normal functions. Only in this file. Only functions used in the current source file should be described
Is an internal function (static), which should be described and defined in the current source file. For
The function used outside should be described in a header file. The source file to use these functions must contain this header file.
What is the difference between static global variables and common global variables? STATIC global variables are only made once to prevent
Referenced in other file units;
What is the difference between static local variables and common local variables: static local variables are initialized only once, And the next
Last result value;
What is the difference between a static function and a common function? The static function has only one copy in the memory.
Maintain a copy in use
2. Local variables of the program exist in (stack), global variables exist in (static zone), and dynamic application for data storage
In (HEAP.
3. The following descriptions and definitions are provided:
Typedef Union {long I; int K [5]; char C;} date;
Struct data {int cat; Date cow; double dog;} too;
Date Max;
The execution result of the statement printf ("% d", sizeof (struct date) + sizeof (max); is: ___ 52 ____
A: date is a union, and the maximum variable type is int [5], which occupies 20 bytes.
It is 20 characters in size.
Data is a struct, and each variable occupies space separately. int4 + date20 + double8 = 32.
So the result is 20 + 32 = 52.
Of course... in some 16-bit editors, int may be 2 bytes, so the result is int2 + date10 + double8 =
20
4. What is the difference between queues and stacks?
Queue first-in-first-out, stack first-in-first-out
5. Write the output content of the following code
# Include <stdio. h>
Int Inc (int)
{
Return (++ );
}
Int multi (int * a, int * B, int * C)
{
Return (* c = * A ** B );
}
Typedef int (func1) (INT in );
Typedef int (func2) (int *, int *, int *);
Void show (func2 fun, int arg1, int * arg2)
{
INCP = & Inc;
Int temp = P (arg1 );
Fun (& temp, & arg1, arg2 );
Printf ("% d \ n", * arg2 );
}
Main ()
{
Int;
Show (multi, 10, & );
Return 0;
}
Answer: 110
7. Please find out the error in the following code
Note: The following code returns a string in reverse order, for example, "ABCD" in reverse order and changes it to "dcba"
1. # include "string. H"
2. Main ()
3 ,{
4. char * src = "Hello, world ";
5. char * DEST = NULL;
6. Int Len = strlen (SRC );
7. DEST = (char *) malloc (LEN );
8. char * D = DEST;
9. char * s = SRC [Len];
10. While (Len --! = 0)
11. d ++ = s --;
12. printf ("% s", DEST );
13. Return 0;
14 ,}
A:
Method 1:
Int main (){
Char * src = "Hello, world ";
Int Len = strlen (SRC );
Char * DEST = (char *) malloc (LEN + 1); // allocate a space for \ 0
Char * D = DEST;
Char * s = & SRC [len-1]; // point to the last character
While (Len --! = 0)
* D ++ = * s --;
* D = 0; // Add \ 0 to the end
Printf ("% s \ n", DEST );
Free (DEST); // after use, the space should be released to avoid Memory leakage.
Return 0;
}
Method 2:
# Include <stdio. h>
# Include <string. h>
Main ()
{
Char STR [] = "Hello, world ";
Int Len = strlen (STR );
Char T;
For (INT I = 0; I <Len/2; I ++)
{
T = STR;
STR = STR [len-i-1]; STR [len-i-1] = T;
}
Printf ("% s", STR );
Return 0;
}
1.-126, 126, what is the number between 28 and? Why?
The answer to the first question should be 4 ^ 3-1 = 63
The rule is n ^ 3-1 (when n is an even number 0, 2, 4)
N ^ 3 + 1 (when n is an odd number of 1, 3, 5)
Answer: 63
2. Use two stacks to implement a queue function? Algorithms and ideas are required!
Set the two stacks to A and B. They are empty at the beginning.
Join:
Push new elements into stack;
Departure:
(1) judge whether stack B is empty;
(2) If it is not empty, all elements in stack a will pop out and push to stack B in sequence;
(3) pop the top element of stack B;
In this way, the complexity of queuing and queuing is still O (1), which is better than the above methods. 3. in C Language
Is the Atool () function used to convert a character to an integer in the library function? What is the prototype of this function?
Function Name: atol
Function: converts a string to an integer.
Usage: Long atol (const char * nptr );
Program example:
# Include <stdlib. h>
# Include <stdio. h>
Int main (void)
{
Long L;
Char * STR = "98765432 ";
L = atol (lstr );
Printf ("string = % s integer = % LD \ n", STR, L );
Return (0 );
}
2. What implementation is applied to a frequently used short function in C language and in C ++?
C is defined by macro, and C ++ is defined by inline.
3. What is a group of links that directly link two signaling points?
PPP point-to-point connection
4. What interfaces does the access network use?
5. What protocols are used by VoIP?
6. What types of software testing are there?
Black Box: white box for testing system functions: testing function functions and various function Interfaces
7. Are you sure the module functions and module interfaces are completed in the team segment of the software design?
Outline Design Phase
8. Enum string
{
X1,
X2,
X3 = 10,
X4,
X5,
} X;
Ask x = 0x801005, 0x8010f4;
9. unsigned char * P1;
Unsigned long * P2;
P1 = (unsigned char X) 0x801000;
P2 = (unsigned long x) 0x810000;
May I ask P1 + 5 =;
P2 + 5 =;
Iii. multiple choice questions:
1. Which of the following protocols does etemedinet use to link to the Internet?
A. HDLc; B. ARP; C. UDP; D. TCP; E. ID
2. network layer protocols:
A. TCP; B. IP; C. ICMP; D. X.25
3. The message scheduling mechanism in Windows is as follows:
A. command queue; B. Command Stack; C. Message Queue; D. Message stack;
4. Unsigned short Hash (unsigned short key)
{
Return (Key>) % 256
}
Hash (16) and hash (256) values are as follows:
A.1.16; B .8.32; c.4.16; d.1.32
4. Find the wrong question:
1. What are the following program errors?
Int A [60] [250] [1000], I, J, K;
For (k = 0; k <= 1000; k ++)
For (j = 0; j <250; j ++)
For (I = 0; I <60; I ++)
A [J] [k] = 0;
Replace internal and external loop statements
2. # define max_cb 500.
Void lmiquerycsmd (struct msgcb * PMSG)
{
Unsigned char ucw.num;
......
For (ucloud num = 0; ucloud num <max_cb; ucloud num ++)
{
......;
}
Endless loop
3. The following is a program to calculate the square of a number. Please find out the error:
# Define square (A) (a) * ())
Int A = 5;
Int B;
B = square (A ++ );
4. typedef unsigned char byte
Int examply_fun (byte gt_len; byte * gt_code)
{
Byte * gt_buf;
Gt_buf = (byte *) malloc (max_gt_length );
......
If (gt_len> max_gt_length)
{
Return gt_length_error;
}
.......
}
5. Q &:
The hidden content of this post must be replied before browsing 12. What is the layer-7 model of ISO? What layer does TCP/UDP belong? What are the advantages and disadvantages of TCP/UDP?
Application Layer
Presentation Layer
Session Layer
Transport Layer
Network Layer
Physical Link Layer
Physical Layer
TCP/UDP belongs to the transport layer
The TCP Service provides data stream transmission, reliability, effective traffic control, full duplex operations, and Multiplexing technologies.
Unlike TCP, UDP does not provide reliable IP protocol mechanisms, stream control, and error recovery functions. Because
UDP is relatively simple. The UDP header contains a few bytes, which consumes less than the TCP load.
TCP: provides stable transmission services with traffic control. The disadvantage is that the packet header is large and the redundancy is poor.
UDP: it does not provide stable services, with a small packet header and low overhead.
1 :( void *) Does PTR and (* (void **) PTR have the same results? PTR is the same pointer.
. (Void *) PTR and (* (void **) PTR values are the same
2: int main ()
{
Int x = 3;
Printf ("% d", X );
Return 1;
}
Why does 1 be returned if the function is not called by other functions?
In Mian, the C standard assumes that 0 indicates successful, and a non-0 value indicates an error. The specific value is the specific error information in a certain project.
1. To assign a value to the absolute address 0x100000, we can use
(Unsigned int *) 0x100000 = 1234;
What should I do if I want to redirect the program to an absolute address 0x100000 for execution?
* (Void (*) () 0x100000 )();
First, we need to forcibly convert 0x100000 into a function pointer, that is:
(Void (*) () 0x100000.
Then call it:
* (Void (*) () 0x100000 )();
You can see more intuitively with typedef:
Typedef void (*) () voidfuncptr;
* (Voidfuncptr) 0x100000 )();
2. An array table is known, and a macro is used to define the number of elements in the data.
# Define ntbl
# Define ntbl (sizeof (table)/sizeof (Table [0])
Interview question: What is the difference and connection between a thread and a process? Does a thread have the same stack? Does the DLL have an independent stack?
The process is dead, but it is only a collection of resources. The real program execution is completed by threads. When the program is started
The operating system creates a main thread for you.
Each thread has its own stack.
Whether there is an independent stack in the DLL. This question is hard to answer, or whether the question itself has a problem. Because DLL
The code in is executed by some threads, and only the thread has a stack. If the code in the DLL is called by the thread in the EXE
Is this DLL not having its own stack? If the DLL code is created by the DLL itself
If the created thread is executed, does the DLL have an independent stack?
The above is about the stack. For the heap, each dll has its own heap, so if it is dynamically allocated from the DLL
It is best to delete the memory from the DLL. If you allocate the memory from the DLL, and then in the EXE or another DLL
Deletion may cause program crash
Unsigned short a = 10;
Printf ("~ A = % u \ n ",~ A );
Char c = 128;
Printf ("c = % d \ n", C );
How much output? And analysis process
Question 1 ,~ A = 0xfffffff5; int value:-11, but uint is output. Therefore, output 4294967285
Question 2: C = 0x10. The output value is int. The highest bit is 1, which is a negative number. Therefore, the value of 0x00 is 12.
8, so the output is-128.
These two questions are all about the highest bit processing when binary is converted to int or uint.
Analyze the following program:
Void getmemory (char ** P, int num)
{
* P = (char *) malloc (Num );
}
Int main ()
{
Char * STR = NULL;
Getmemory (& STR, 100 );
Strcpy (STR, "hello ");
Free (STR );
If (STR! = NULL)
{
Strcpy (STR, "world ");
}
Printf ("\ n str is % s", STR );
Getchar ();
}
What is the output result? I hope you can tell me the reason. Thank you first.
Output STR is world.
Free is the memory space pointed to by the released Str. Its value still exists.
So after free, there is a good habit of converting STR = NULL.
In this case, the memory of the STR pointing to the space has been recycled. If there is still a space allocation operation before the output statement
Space may be reassigned to other variables,
Although this program does have a big problem (you have already made it clear), it usually prints
World.
This is because memory management in a process is generally not completed by the operating system, but by the database function itself.
When you malloc a piece of memory, the management library applies for a piece of space from the operating system (may be larger than the one you applied
), And then record some management information in this space (usually a little before the memory you applied for), and will be available
Memory Address. But when the memory is released, the management library usually does not return the memory to the operating system, so you
Yes, you can continue to access this address, ........ I already said it upstairs. It's best not to do this.
Why is Char A [10], strlen (a) equal to 15? Running result
# Include "stdio. H"
# Include "string. H"
Void main ()
{
Char AA [10];
Printf ("% d", strlen (AA ));
}
Sizeof () is irrelevant to initial initialization;
Strlen () is related to initialization.
Char (* Str) [20];/* STR is an array pointer, that is, a pointer to an array .*/
Char * STR [20];/* STR is a pointer array whose elements are pointer-type data .*/
Long a = 0x801010;
A + 5 =?
0x801010 in binary format: "1000 0000 0001 0000 0001", with a decimal value of 0000
In addition, 5 is 8392725 Luo.
This article comes from [bingo.com: http://www.bingojob.cn], the original address: http://www.bingojob.cn/zixun/ArticleView.aspx? Rid = e14fbfb8-1dc0-4e0b-a883-8c1ab5bcce10