What is the concatenation operator? Ans. The concatenation operator (##) is used to concatenate (combine) two separate strings into one single string. The concatenation operator is often used in C macros, as the following program demonstrates: #include #define SORT(x) sort_function ## x void main(void); void main(void) { char* array; int elements, element_size; ... SORT(3)(array, elements, element_size); ... } In the preceding example, the SORT macro uses the concatenation operator to combine the strings sort_function and whatever is passed in the parameter x. This means that the line SORT(3)(array, elements, element_size); is run through the preprocessor and is translated into the following line: sort_function3(array, elements, element_size); As you can see, the concatenation operator can come in handy when you do not know what function to call until runtime. Using the concatenation operator, you can dynamically construct the name of the function you want to call, as was done with the SORT macro. - Study24x7
Social learning Network
24 Mar 2023 10:30 AM study24x7 study24x7

What is the concatenation operator? Ans. The concatenation operator (##) is used to concatenate (combine) two separate strings into one single string. The concatenation operator is often used in C macros, as the following program d...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles