C

typedef versus #define in C\C++

typedef and #define are commonly used in C\C++. Below are some of the difference and similarity between them typedef is used to give data type a new name. #define is a C\C++ directive which is used to define alias. // BYTE can be used in place of unsifned char typedef [...]

2022-07-15T18:18:59+05:30Categories: Programming|Tags: |

Defining Macro in C/C++

A macro in C/C++ is a fragment of code which has been given a name. Whenever the name is used, it is replaced by the contents of the macro. There are two kinds of macros. They differ mostly in what they look like when they are used. Object-like macros resemble [...]

2022-07-15T18:17:43+05:30Categories: Programming|Tags: |

What are Function Pointer in C++

Definition Function pointers point to executable code at a particular piece of memory. Dereferencing the function pointer allows the code in the memory block to be executed. Main benefit of function pointers is that they provide a straightforward mechanism for choosing a function to execute at runtime. Important points about [...]

2024-05-11T16:35:21+05:30Categories: Programming|Tags: , |

typedef in C/C++

The typedef declaration provides a way to declare an identifier as a type alias in C/C++. It is used to replace a possibly complex type name. We can also use #define for defining alias. typedef char char_t, *char_p, (*fP)(void); Above example declares char_t to be an alias for char char_p to [...]

2022-07-15T18:15:02+05:30Categories: Programming|Tags: |

unorderd_set in C+++

Unordered sets are containers that store unique elements in no particular order, and which allow for fast retrieval of individual elements based on their value. In an unordered_set, the value of an element is at the same time its key, that identifies it uniquely. Keys are immutable, therefore, the elements [...]

2017-08-19T18:29:15+05:30Categories: Programming|Tags: |

Unordered_map in C++

Unordered_map provides a functionality of map i.e. it store the elements in key value pair and with unique key only. Unordered_map internally uses the hashing to achieve this. It internally uses a hash table to implement this hashing feature.  In an unordered_map elements are stored in a key value pair [...]

2017-08-19T11:22:19+05:30Categories: Programming|Tags: |

Conditional Operator nesting

The ternary conditional operator has right-to-left associativity. For example, x?y?z:u:v; be simply interpreted as: if(x) { if(y) { z; } else { u; } } else { v; } Also x = a ? b : c ? d : e; is interpreted as: x = a ? b : [...]

2017-06-09T11:04:33+05:30Categories: Programming|Tags: |

C interview questions

Compare and contrast compilers from interpreters. Compilers and interpreters often deal with how program codes are executed. Interpreters execute program codes one line at a time, while compilers take the program as a whole and convert it into object code, before executing it. The key difference here is that in [...]

2017-06-03T13:37:54+05:30Categories: Programming|Tags: , |

When to use Pointer-to-Pointer

When you want to change the value of variable passed to a function as the function argument, and preserve updated value outside of that function, you require pointer(single pointer) to that variable. void modify(int* p){ *p = 10; } int main(){ int a = 5; modify(&a); cout << a << [...]

2019-02-22T21:04:44+05:30Categories: Programming|Tags: |

Carriage return, Line feed and Form feed

Carriage return means to return to the beginning of the current line without advancing downward. This is commonly escaped as "\r", abbreviated CR, and has ASCII value 13 or 0x0D. Linefeed means to advance downward to the next line. Used as "newline", it terminates lines (commonly confused with separating lines). [...]

2017-03-22T13:45:39+05:30Categories: Programming|Tags: |
Go to Top