What is the difference between array and enum in C ?

Array is a variable that can contain multiple elements with index starting from 0 whereas enum is an user defined datatype that contains a list of members for which an integer constant is assigned starting from 0. in case of enum the numbers starting from 0 are not indexes whereas in case of an array they are indexes. … Read more

Assembly x86 – “leave” Instruction

LEAVE is the counterpart to ENTER. The ENTER instruction sets up a stack frame by first pushing EBP onto the stack and then copies ESP into EBP, so LEAVE has to do the opposite, i.e. copy EBP to ESP and then restore the old EBP from the stack. See the section named PROCEDURE CALLS FOR BLOCK-STRUCTURED LANGUAGES in Intel’s Software Developer’s Manual Vol 1 if you want to read more about how ENTER and LEAVE work. enter n,0 is exactly equivalent … Read more

How to empty a char array?

using in general if the array is in scope, or if you only have the pointer value, and nMembers is the number of elements in the array. EDIT Of course, now the requirement has changed from the generic task of clearing an array to purely resetting a string, memset is overkill and just zeroing the first element … Read more

Still Reachable Leak detected by Valgrind

There is more than one way to define “memory leak”. In particular, there are two primary definitions of “memory leak” that are in common usage among programmers. The first commonly used definition of “memory leak” is, “Memory was allocated and was not subsequently freed before the program terminated.” However, many programmers (rightly) argue that certain … Read more

Initializing array of structures

There’s no “step-by-step” here. When initialization is performed with constant expressions, the process is essentially performed at compile time. Of course, if the array is declared as a local object, it is allocated locally and initialized at run-time, but that can be still thought of as a single-step process that cannot be meaningfully subdivided. Designated … Read more

printf not printing to screen

Like @thejh said your stream seems to be buffered. Data is not yet written to the controlled sequence. Instead of fiddling with the buffer setting you could call fflush after each write to profit from the buffer and still enforce the desired behavior/display explicitly.

Difference between “move” and “li” in MIPS assembly language

The move instruction copies a value from one register to another. The li instruction loads a specific numeric value into that register. For the specific case of zero, you can use either the constant zero or the zero register to get that: There’s no register that generates a value other than zero, though, so you’d have to use li if you wanted some … Read more

Difference between sizeof(char) and sizeof(char *)

char is a character and sizeof(char) is defined to be 1. (N1570 6.5.3.4 The sizeof and _Alignof operators, paragraph 4) char* is a pointer to a character and sizeof(char*) depends on the environment. It is typically 4 in 32-bit environment and 8 in 64-bit environment. In typical environment where sizeof(char*) > sizeof(char), malloc(sizeof(char*)*len + 1) will (at least try to) allocate more memory than malloc(sizeof(char)*len + 1) if len is small … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)