background preloader


Facebook Twitter

C Enumeration (Enum): Examples and Where it is used? Difference between C and Embedded C. Key difference: C is a type of computer programming language.

Difference between C and Embedded C

C was originally developed by Dennis Ritchie at AT&T Bell Labs between 1969 and 1973. It has a free-format program source code. Split a string into two based on char location. The C Book — Const and volatile. Embedded systems - Writing generic code when your target is a C compiler - Software Engineering Stack Exchange. The best way to handle this is to actually write your algorithms in a language independent pseudo code.


Then, you can create a reference implementation in a language of choice, like C, carefully noting the edge cases that make this implementation tied to a particular memory model, data type model, byte sizes, bit handling capabilities, loop exit conditions weirdness ( think floating point ) types size overflow, etc. etc. The reason this is a good strategy is that you will never achieve true portability with any known set of language tools, compilers, cross compilers, diagramers, prototypers.

It is just not truly tractable. Once you have created a few reference implementations, ideally in very diverse languages ( think Lisp or Prolog ) you will be able to more fully identify, understand and anticipate how your code will adapt to different platforms; and learn how to write pseudo code, move carefully toward an implementation and track the edge cases and dependencies. Function overloading in C.

C strcmp() The strcmp() function compares two strings and returns 0 if both strings are identical.

C strcmp()

C strcmp() Prototype int strcmp (const char* str1, const char* str2); The strcmp() function takes two strings and return an integer. The strcmp() compares two strings character by character. If the first character of two strings are equal, next character of two strings are compared. It is defined in string.h header file. Return Value from strcmp() Example: C strcmp() function #include <stdio.h>#include <string.h> int main(){ char str1[] = "abcd", str2[] = "abCd", str3[] = "abcd"; int result; // comparing strings str1 and str2 result = strcmp(str1, str2); printf("strcmp(str1, str2) = %d\n", result); // comparing strings str1 and str3 result = strcmp(str1, str3); printf("strcmp(str1, str3) = %d\n", result); return 0;} Output strcmp(str1, str2) = 32 strcmp(str1, str3) = 0 The first unmatched character between string and is third character.

C - socket connect() vs bind() Combining 4 bytes into one long int. 4 byte to float conversion. How to pass ENUM as function argument in C. How to round off Float to 2 decimal places ATmega16 iar work. Floating point - Rounding Number to 2 Decimal Places in C. Return array from function in C. C programming does not allow to return an entire array as an argument to a function.

Return array from function in C

However, you can return a pointer to an array by specifying the array's name without an index. If you want to return a single-dimension array from a function, you would have to declare a function returning a pointer as in the following example − int * myFunction() { . . .} Second point to remember is that C does not advocate to return the address of a local variable to outside of the function, so you would have to define the local variable as static variable. Now, consider the following function which will generate 10 random numbers and return them using an array and call this function as follows − When the above code is compiled together and executed, it produces the following result −

Objective c - combine/merge two bytes into one...? C Data Types - Handbook. C Data Types C/C++ provides various data types that can be used in your programs.

C Data Types - Handbook

In general, you'd commonly use: int for most variables and "countable" things (for loop counts, variables, events) char for characters and strings float for general measurable things (seconds, distance, temperature) uint32_t for bit manipulations, especially on 32-bit registers The appropriate stdint.h types for storing and working with data explicitly at the bit level. How do I use extern to share variables between source files in C? C Enumeration (Enum): Examples and Where it is used? C Memory Allocation Using malloc(), calloc(), free() & realloc()

In C, the exact size of array is unknown until compile time, i.e., the time when a compiler compiles your code into a computer understandable language.


So, sometimes the size of the array can be insufficient or more than required. Dynamic memory allocation allows your program to obtain more memory space while running, or to release it if it's not required. In simple terms, Dynamic memory allocation allows you to manually handle memory space for your program. Although, C language inherently does not have any technique to allocate memory dynamically, there are 4 library functions under "stdlib.h" for dynamic memory allocation. Embedded Interview Questions: Function Pointers and Callbacks in C. C get nth byte of integer.

Free Online IDE and Terminal.


Power function. Questions to see.