In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use C language functions and macros". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn how C language functions and macros are used.
Functions and macros
Macros are directly replaced and expanded by preprocessors, and the compiler does not know that macros exist.
A function is an entity compiled directly by the compiler, and the calling behavior is determined by the compiler.
Using macros multiple times will result in an increase in the size of the final executable program
The function is executed by a jump, and only one function body exists in memory.
Macros are more efficient than functions because they are expanded directly and have no calling overhead.
When a function is called, an activity record is created, which is not as efficient as a macro
Let's take a look at an example of functions and macros. Let's look at this program first:
# include # define RESET (p, len)\ while (len > 0)\ ((char*) p) [--len] = 0 void reset (void* p, int len) {while (len > 0) ((char*) p) [--len] = 0;} int main () {int array [] = {1,2,3,4,5}; int len = sizeof (array); int I = 0 RESET (array, len); for (iTuno; I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.