The realloc function in C Programming

https://youtu.be/pueYFVgLb7o #include <stdio.h> #include <stdlib.h> int main() { int *ptr = malloc(sizeof(int)); if (ptr) { printf("Allocated bytes : %zu\n", sizeof *ptr); } int *newPtr = realloc(ptr, 10 * sizeof(int)); if…

The calloc function in C Programming

https://youtu.be/MpF-_J91P2A #include <stdio.h> #include <stdlib.h> int main() { int *ptr = calloc(1, sizeof(int)); int *arrPtr = calloc(3, sizeof(int)); if (ptr) { printf("The initial Value is : %d\n", *ptr); *ptr =…

malloc function in C programming

https://youtu.be/Sp29Gz2Mars #include <stdio.h> #include <stdlib.h> typedef struct malloc_example { char a; int i; } MyStruct; int main() { MyStruct *sptr = malloc(sizeof(MyStruct)); int *ptr = malloc(sizeof(*ptr)); char *cptr = malloc(sizeof(char));…

Built In Macros in C Programming

https://youtu.be/PKsL4tt-8uw #include <stdio.h> void some_function() { printf("Name of the function is %s\n", __func__); } int main() { printf("Line number is %d\n", __LINE__); printf("The file name is %s\n", __FILE__); some_function(); return…

The #ifndef directive in C

https://youtu.be/wM6HLwOfML8?si=ieNeTqV7ry0TomTU #include <stdio.h> #define SOME_MACRO int main() { #ifndef SOME_MACRO printf("Will not compiled\n"); #endif #ifndef NO_MACRO printf("This one will be printed\n"); #endif #ifndef NEW_MACRO #define NEW_MACRO printf("Macro defined\n"); #endif return…

The #ifdef directive in C

https://youtu.be/H0-FR6ozhOc?si=zl88UVu1wYhQYYDJ #include <stdio.h> #define OUR_MACRO int main() { #ifdef OUR_MACRO printf("Will get compiled!\n"); #endif #ifdef NO_MACRO printf("Will not get compiled\n"); #endif return 0; }

The #if directive in C

https://youtu.be/4vS3vJNJsog #include <stdio.h> #define FLAG 150 int main() { #if FLAG < 150 printf("This will not get compiled\n"); #elif FLAG == 150 printf("This will get compiled\n"); #else printf("This one will…