MasterofProject

Common C++ written examination questions (including answers) 2

Label C++CStringlanguageprogramming
19053 people read comments(14) Collection Report
Classification:

Circulating on the Internet a common C + + written questions summary, for you have a reference to students and the need to find a job, because the original is longer, hence the serial form, is expected to need to serialize about 10, students have the patience, please have to go, I believe will be harvested.

Ahead of that, subject to in the network, the answer is for reference only, if students think what problem have objections, welcome to discuss!

Title 11-20

11 what is the problem with the following code?
Test3 Void (STR1 char*)
{
String[10] char;
If (strlen (STR1) <=10)
{
Strcpy (string, STR1);
}
}
= = array bounds
Copy ==strcpy end mark is find string / so if string not encountered in the input / output will have been copied, until it encounters 0, above 123 resulting bounds

Recommended using strncpy and memcpy
--------------------------------------------------------------------------
12 what is the problem with the following code?
MAX_SRM #define 256
Get_SRM_no DSN ()
{
Static int SRM_no; / / no initial value is not here?
Int I;
For (I=0; I<MAX_SRM; I++, SRM_no++)
{
SRM_no = MAX_SRM;
If (MY_SRM.state==IDLE)
{
Break;
}
}
If (I>=MAX_SRM)
Return (NULL_SRM);
Else
SRM_no return;
}
The system will initialize the int static variable to 0, but the value will always be saved, so that it is not re entered...
--------------------------------------------------------------------------
13 write operation results:
{// test1
Str[] char = "world"; cout "sizeof (STR)"":";
*p char = cout; sizeof "str (P)"":";
I char = 10; cout "sizeof (I)"":";
*pp void = malloc (10); cout "sizeof (P)" endl;
}
6:4:1:4
--------------------------------------------------------------------------
14 write operation results:
{// test2
V union {
X struct {
Char s1:2 unsigned;
Char s2:3 unsigned;
Char s3:3 unsigned;
X};
Char c unsigned;
V};
V.C = 100;
Printf ("%d", v.x.s3);
}
Three
--------------------------------------------------------------------------
15 using C++ to write a program, how to judge an operating system is the 16 or 32? Can't use sizeof () function
A1:
16 bit system,
I int = 65536;
Cout < I; / / output 0;
I int = 65535;
The cout I / -1 output;
32 bit system,
I int = 65536;
Cout < I; / / output 65536;
I int = 65535;
Cout < I; / / output 65535;
A2:
A int = ~0;
If (a>65536)
{
Cout<< "32 <<endl" bit;
}
Else
{
Cout<< "16 <<endl" bit;
}

--------------------------------------------------------------------------
16.C and C++ what is the difference?
From the mechanism: C is process oriented (but C can also write object-oriented programs); object oriented C + + provides. But,
C++ to write object-oriented programs easier than C
From applicable direction: C for small code size requirements, high efficiency of occasions, such as embedded; C + + for more on top of the and complex; the core of the Llinux most is written in C, because it is a software system, efficiency is extremely demanding.
From the name can also be seen that C + + C than many +, C + + is a superset of C; so why not call C + and called C + +? Is it because C + + than
C for the expansion of things too much, so in the back of the C on the two +; so it became c++
C language is a structured programming language, C++ is an object-oriented programming language.
C++ focuses on the object rather than the process, focusing on the design of the class rather than the logic of the design.
--------------------------------------------------------------------------
17 in the case of no third party parameters, the value of the exchange of two parameters
<stdio.h> #include
Main void ()
{
I=60 int;
J=50 int;
I=i+j;
J=i-j;
I=i-j;
Printf ("i=%d/n", I);
Printf ("j=%d/n", J);
}
Method two:
I^=j;
J^=i;
I^=j;
Method three:
/ / and do not overflow with the addition and subtraction,
A = a+b- (b=a)
--------------------------------------------------------------------------
18 about the domain of the interview questions (why output is a strange character)
A.T ='b'; the effect is equivalent to'b' a.t= & 0xf;
'b'-- > 01100010
0xf & -->>00000010'b'
So the special character of the output Ascii code is 2

T:4 char; 4bit is the character variable, the same
Short i:8 unsigned; is the 8bit of the unsigned short shaping variable
--------------------------------------------------------------------------
I=10 j=10, 19.int, k=3; k*=i+j; k the final value is?
Sixty
--------------------------------------------------------------------------
20 ways to communicate between processes have?
There are shared memory, pipeline, Socket, message queue, DDE, etc. in the process of inter process communication.

 

Unfinished, to be continued.

DISCRETION IS ADVISED VIEWER
top
Zero
tread
Zero
Guess you're looking for
View comments
* the above user comments only represent their personal views, does not represent the views or position of the CSDN website
    personal data
    • Visit566784 times
    • Integral:Ten thousand three hundred and eighty-four
    • Grade
    • Rank:789th name
    • Original210
    • Reproduced:7
    • Translation:0
    • Comments:2855 article
    biography
    Absorbedimage processing,Data mining and machine learning. Communication and cooperation please blog post or mail to fzuo@foxmail.com. Language is good atC/C++, Java, Prolog, Haskell, a small amount of Python and VB. Like to useRData mining and analysis, usingMatlabTo study the image algorithm.
    Blog column
    My books
    Exchange learning group for image processing
    Scan under two-dimensional code can be added
    Image processing learning group (529549320)
    "Click or scan two-dimensional code to add image processing to exchange learning group
    Latest comments