Lua – Number to string behaviour

In Lua 5.2 or earlier, both tostring(10) and tostring(10.0) result as the string “10”. In Lua 5.3, this has changed: That’s because Lua 5.3 introduced the integer subtype. From Changes in the Language: The conversion of a float to a string now adds a .0 suffix to the result if it looks like an integer. (For instance, the float 2.0 will be printed as 2.0, not … Read more

Error: “Access not within mapped region at address” (Valgrind)

i am having a probem with valgrind givin me an error saying “Access not within mapped region at address 0x8”. It then says “at 0x400606: append_linked_list (testing2.c:64) by 0x400563: main (testing2.c:32)”. Line 64 is list->tail->next = newNode;, and line 32 is just calling the function which line 64 is in append_linked_list(list, (void *) argv[i]);. When … Read more

Structure padding and packing

Padding aligns structure members to “natural” address boundaries – say, int members would have offsets, which are mod(4) == 0 on 32-bit platform. Padding is on by default. It inserts the following “gaps” into your first structure: Packing, on the other hand prevents compiler from doing padding – this has to be explicitly requested – under GCC it’s __attribute__((__packed__)), so the following: … Read more

What is the job of autogen.sh when building a c++ package on Linux

The steps: The autogen.sh script generates the configure script (from configure.ac, using autoconf) and any files it needs (like creating Makefile.in from Makefile.am using automake). This requires autotools to be installed on your system, and it must be run when checking out the project from source control (if configure isn’t checked in). People who download source tarballs can usually skip this step, because output of this … Read more

Can’t understand the working of getint() in C as per K&R

The getint() function only reads digits from the input. If it gets a character that is not a digit or a + – sign at the beginning it will call ungetch() to push the character back into the input buffer so it could be read by some other function call. getint() will go on returning … Read more

Categories c Tags

getc() vs fgetc() – What are the major differences?

From the Advanced Programming in Unix Environment: … The difference between getc and fgetc is that getc can be implemented as a macro, whereas fgetc cannot be implemented as a macro. This means three things: The argument to getc should not be an expression with side effects. Since fgetc is guaranteed to be a function, we can take its address. This allows us to pass the address of fgetc as … Read more

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