When is it ok to use a global variable in C?

Variables should always have a smaller scope possible. The argument behind that is that every time you increase the scope, you have more code that potentially modifies the variable, thus more complexity is induced in the solution. It is thus clear that avoiding using global variables is preferred if the design and implementation naturally allow … Read more

How to use shared memory with Linux in C

There are two approaches: shmget and mmap. I’ll talk about mmap, since it’s more modern and flexible, but you can take a look at man shmget (or this tutorial) if you’d rather use the old-style tools. The mmap() function can be used to allocate memory buffers with highly customizable parameters to control access and permissions, and to back them with file-system storage if … Read more

Convert Char to String in C

To answer the question without reading too much else into it i would You could use the second line in a loop with what ever other string operations you want to keep using char’s as strings.

“Nothing to be done for makefile” message

If you don’t specify a target on the command-line, Make uses the first target defined in the makefile by default. In your case, that is makefile:. But that doesn’t do anything. So just remove makefile:.

Level vs Edge Trigger Network Event Mechanisms

The short answer is, edge-triggered means that you get notified only when the event is detected (which takes place, conceptually, in an instant), while level-triggered means you get notified whenever the event is present (which will be true over a period of time). For example, in an edge-triggered system, if you want a notification to … Read more

How to normalize a mantissa

A floating point number is normalized when we force the integer part of its mantissa to be exactly 1 and allow its fraction part to be whatever we like. For example, if we were to take the number 13.25, which is 1101.01 in binary, 1101 would be the integer part and 01 would be the fraction part. I could represent 13.25 as 1101.01*(2^0), but this isn’t normalized because the … Read more

how to stop a loop arduino

Arduino specifically provides absolutely no way to exit their loop function, as exhibited by the code that actually runs it: Besides, on a microcontroller there isn’t anything to exit to in the first place. The closest you can do is to just halt the processor. That will stop processing until it’s reset.

%p Format specifier in c

If this is what you are asking, %p and %Fp print out a pointer, specifically the address to which the pointer refers, and since it is printing out a part of your computer’s architecture, it does so in Hexadecimal. In C, you can cast between a pointer and an int, since a pointer is just … Read more

malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))

malloc(sizeof(int)) means you are allocating space off the heap to store an int. You are reserving as many bytes as an int requires. This returns a value you should cast to int *. (A pointer to an int.) As some have noted, typical practice in C is to let implicit casting take care of this. malloc(sizeof(int*)) means you are allocating space off the heap … Read more

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