Posts

Why C is the most powerful language

  Modularity and less keyword unlike other languages that have dedicated keyword for simple math functions,   it has libraries more instead of keywords   that makes it   efficient . Complex Declarations   , using complex declaration you can define any real world entity Storage classes such as extern & register, inline, volatile, const keyword which are low level in nature etc. Direct   mapping of constructs to memory segments Pointers with   Pointer typecasting & treating Function name as pointer ,   i think pointers are useless without pointer typecasting. Function name is treated as pointer in C which makes it very powerful and also pointer arithmetic. Wide varieties of types   from long long to char , floating type such as float or double but has   weak type checking. void * / int * as a generic data storage Use of   expression   in every place whether it’s in   for , while or if for(expression ; expression; e...

Firmware Interview Questions

 He asked a puzzle that you have 500 switches and all are OFF. Now someone came and make all of them ON. Now a second person came and flip all the second switch and then 3rd came and flip all the 3rd switch and so on till 500. So tell me how many switch will be on after completing the entire process. synchronization mechanisms for threads associating a mutex with a condition variable solved it mutex reursive binary semaphore and mutex Clone a linked list into two different linked lists such that one list contains the first half of the existing linked list, in the same order, and the other list contains the other half. Time complexity should be minimum. How would you represent a sparse matrix using minimum space complexity such that all elements can be accessed through their row and column indices? Prepare a STAR matrix parse matrix. C programming to the depth. like triple pointers, linked lists, algorithms etc. 1st F2F was on checking the logical ability and problem solving along w...

Basic Parsing using strtok

  C string.h library provides functionalities for parsing like strtok() string tokenizer is a functionality which will tokenize the string using the delimiter It basically replaces the delimiter string(char *) with '\0' next time we do strtok we give NULL as input instead of char* token with delimiter string.  char *strtok(char *token, char* delimiter);  Usage of strtok in Computer Networks for IP Address Parsing #include <string.h> #include <stdio.h> #include <stdlib.h> int main() {   int val;   char c[64]="192.168.0.0";  // be careful it should be character array not character pointer   char *tok;   tok=strtok(c,".");   while(tok != NULL)   {      val = atoi(tok);      printf("%s %d %x %o\n",tok,val,val,val);      tok=strtok(NULL,".");   } }   Wide application of strtok can be used for questions like:- " I LOVE MY COUNTRY " " COUNTRY MY LOVE I" ...

Linking of Programs using Header

Image
                          Linking of Programs using Header  It's only takes 4 steps to link 2 programs 1) Keep the name of the header and name of the file same 2) Declare all function declarations in the name.h as defined in name.c 3) Now call the header file name.h using #include "name.h" in main.c 4) Compile both the binaries together using gcc command. It is Shows same behavior as in inheritance in C++

Vim Practical useful tips

  :g/^$/d (for removing extra empty lines) gg=G (for indentation) :se hls (to highlight an identifier) :syn off (for decreasing brightness in vi editor) :vsp <filename> for opening split window [Filename should be in current directory] :sp <filename> for opening split window horizontally [Filename should be in current directory] CTAGS usage in VIM  ------------------ For creation of tag file we need to run ctags command in linux as given below ctags --langmap=c:.c.h.x -h .h.x --tag-relative=no -VR >/dev/null & or ctags -R * :se tags=$PWD<press-tab to replace $PWD with actual present path>/tags Crtl+} braces to jump to definition Ctrl+T to jump back  Shift/Crtl + 5 for toggling(jumping) to end of the block(from '{' to '}') vim -t <funcname> (to jump to function defination after creation of tag file) :100 (to jump to line number 100 in a text file) :$ (to jump to end of the file) 44yy (for copying 44 lines) p (to paste code from yy command...

Optimization of C/C++ Program

                                 Optimization of C/C++ Program  gcc -O3 <c-filename.c> #pragma GCC optimize("O3")  or #pragma GCC optimize("Ofast")    #pragma GCC target("avx,avx2,fma") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #pragma GCC optimization ("unroll-loops") #pragma GCC optimization ("omit-frame-pointer") inline functions for small functions Always use Assembly based library instead of writing algo from scratch or Open-source library Example:- For AES Algo we have AES Assembly instructions that is the best optimization https://en.wikipedia.org/wiki/AES_instruction_set use your own designed library function or else use C++ library functions i.e. std::memcpy as they are better than C counter part. process affinity/core binding zero-copy mechanism to pass buffer used Sha...

List of Projects Idle for C/C++

 C Preprocessor  B Compiler(B Programming Language)  Small subset of C Compiler having RISC-V/ARM specific instruction emitting out Debugger JavaScript/HTML framework like Svelte or UI scripted language to generate a native GUI like Qt as output Windows installer using C or Julia BuildSystem like CMake in Julia LINPACK, BLAS , POSIX, CLayout library binding for Julia using C Interfacing  REST API like https://github.com/PedroFnseca/rest-api-C Abstractor utility - it will be used to remove function prototypes in header if not used,  define func prototypes in header which are used in other files, non-used will be removed from header C++ convertor to C AI OS, a UI windows designed as terminal, which takes input and output using DeepSeek and also commands like Pick OS MSI Windows Installer(.msi) C-Book dictionary, a GUI based dictionary on C Programming language File explorer Notepad++ for linux Assembler Linker and Loader Chatbot lexer and yacc Onscreen-Keyboa...