1) The defined struct is not initialized;
2) sprintf is insecure;
If you do not pay attention to these two points, it may affect the robustness of the software!
3) if (1 1)
4) memset (buffer, 0, size) should be changed to memset
If you try to directly use the member function of C ++ as the callback function, an error will occur, and even compilation will fail. Through data query, it is found that the error is that common C ++ member functions imply a passing function as a
1 C compiler preprocessing Function
String replacement, including header files, universal module Extension
2. compiler features
PortableCode
Uncertain
Undefined
Bad code
Write portable code: 1) it is best to strictly follow the language
Qsort is used for sorting. This question cannot be entered using cin. Otherwise, it will not work if it encounters a space.
It is mainly about the writing method and condition judgment of qsort function sorting.
Description
The program that uses
Most programmers have learned C before learning C ++ and are used to C-style (type) conversion. When writing C ++ (Program), sometimes we may be a bit fuzzy when using static_cast and reinterpret_cast. In this article, I will explain what
This time, because the project is divided into multiple DLL modules, and the new memory block in a DLL module may traverse other DLL modules, in the end, it may not be destroyed in the DLL it was born, which may cause memory allocation recovery
The initial purpose of trait technique is to manage template parameters. Sometimes the template requires several parameters, but some parameters are often closely related to main parameters. In this case, you can use the trait technique, export the
(1)
Generally, C compilers that follow the GNU standard, such as GCC (3.0 and later) have the _ attribute _ mechanism, and C compilers that do not use GNU, such as Vc, you can also execute other functions before or after main (). If not, it can be
Listing 1 time1.c-output the current date and time in different formats # include # include # define bufsize 128 main () {time_t tval; struct TM * now; char Buf [bufsize]; char * fancy_format = "or getting really fancy: \ n "" % A, % B % d, day %
The following code can be used to test the code running time.
1. Clock () method. The time precision of this method is millisecond.
# Include # include using namespace STD; int _ tmain (INT argc, _ tchar * argv []) {clock_t starttime, endtime;
Reverse and resize
The reverse of the vector only adds the capacity of the vector, but the size does not change!Resize also changes the capacity and size of the vector!
Reserve is a container reserved space, but does not actually create element
Parameter transfer
(1) the initialization of the parameter is the same as that of the variable. If the parameter has a non-reference type, the value of the real parameter is copied. If the parameter is of the reference type, it is only the alias
C ++ STD: String's "copy at read" technology!
Zhao Yu
Original: Http://coolshell.cn /? P = 1443
C ++'s STD: string is also a copy technology!
Hey, you are not mistaken. I am not wrong either. It is a copy technology during reading. What? My
Original article:Http://cocre.com /? P = 873
It doesn't matter if you scold my friends in the reply. If you are free, read my other article 《Ten things that annoy programmers, Our cute programmer.
If you find the article interesting, you can
Original article:Http://cocre.com /? P = 933--Cool Shell
Previously Published 《Six abnormal C Hello World programs[Cool shell link] [csdn link] is mainly used to demonstrate some abnormal C language gameplay. I also showed you that the program
Author: zhanghx6986 Source: http://blog.csdn.net/zhanghx6986
Although it has been some time since I used C language for development on UNIX, I have to admit that my unit test is not doing well. Just
From: http://blog.sina.com.cn/s/blog_4a0a39c30100ckzd.html
JPEG is the abbreviation of joint photographic Experts Group (joint image expert group). The file is named ". jpg "or ". JPEG is a common image file format on the Internet. It is famous
The parameters of the virtual base class constructor must be initialized by the newly derived class, even if it is not directly inherited,
The constructor of the virtual base class of the sample program is executed only once:
# Include # Include #
For constructor: first execute the base class, then execute the object member, and finally execute
For destructor: first execute the derived class, then execute the object member, and finally execute
That is, the structure order is opposite to the
The first type of library we will create is the dynamic link library (DLL ). Using DLL is an excellent way to reuse code. You don't have to re-implement the same routine in every program you create, but you just need to write these routines once and
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