error: function returns address of local variable

I’m beginner with C and I am learning on my own. I am creating the following function: I am basically trying to return an appended string, but I get the following error: “error: function returns address of local variable”, any suggestions, how to fix this?

Casting a pointer to an int

I am writing my own functions for malloc and free in C for an assignment. I need to take advantage of the C sbrk() wrapper function. From what I understand sbrk() increments the program’s data space by the number of bytes passed as an argument and points to the location of the program break. If … Read more

What do the dup() and dup2() systems really do?

Both make a new file descriptor corresponding to an existing open file description. Most properties between the old and new fd (like position) are shared; the only property I can think of that’s not shared is the close-on-exec flag. The difference between dup and dup2 is that dup assigns the lowest available file descriptor number, … Read more

Trim a string in C [duplicate]

There is no standard library function to do this, but it’s not too hard to roll your own. There is an existing question on SO about doing this that was answered with source code.

Allocating char array using malloc

Yes, it’s a matter of style, because you’d expect sizeof(char) to always be one. On the other hand, it’s very much an idiom to use sizeof(foo) when doing a malloc, and most importantly it makes the code self documenting. Also better for maintenance, perhaps. If you were switching from char to wchar, you’d switch to … Read more

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