munmap_chunk(): invalid pointer

In the function second(), the assignment word = “ab”; assigns a new pointer to word, overwriting the pointer obtained through malloc(). When you call free() on the pointer later on, the program crashes because you pass a pointer to free() that has not been obtained through malloc(). Assigning string literals does not have the effect of copying their content as you might have thought. To … Read more

Categories C Tags

how to open an mp3 file with c

I think we cannot open an mp3 file this way , like any regular text file. We have to use a codec , to actually play the mp3 file , or atleast use a library which has one. Do take a look at these places. How to play MP3 files in C? SDL Sound Mix … Read more

How to convert an int to string in C?

EDIT: As pointed out in the comment, itoa() is not a standard, so better use sprintf() approach suggested in the rivaling answer! You can use itoa() function to convert your integer value to a string. Here is an example: If you want to output your structure into a file there is no need to convert any value beforehand. You can just use … Read more

error: called object is not a function or function pointer

As for what the error means: 2(x&y) tells the compiler to call the function 2, passing x&y as an argument (just like printf(“hi”) means “call printf and pass “hi” as an argument“). But 2 isn’t a function, so you get a type error. Syntactically speaking, whenever you have a value followed by (, that’s a function call.

Categories C Tags

‘do…while’ vs. ‘while’

If you always want the loop to execute at least once. It’s not common, but I do use it from time to time. One case where you might want to use it is trying to access a resource that could require a retry, e.g.

Invalid read of size 8 – Valgrind + C

The problem is that you’re freeing the sym, then trying to access a value from the (now-freed) data: sym->next. You probably want something like this for the inner loop:

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