warning: assignment makes integer from pointer without a cast

When you write the statement the compiler sees the constant string “abcdefghijklmnop” like an array. Imagine you had written the following code instead: Now, it’s a bit clearer what is going on. The left-hand side, *src, refers to a char (since src is of type pointer-to-char) whereas the right-hand side, otherstring, refers to a pointer. This isn’t strictly forbidden because you may want … Read more

What is the difference between char s[] and char *s?

The difference here is that will place “Hello world” in the read-only parts of the memory, and making s a pointer to that makes any writing operation on this memory illegal. While doing: puts the literal string in read-only memory and copies the string to newly allocated memory on the stack. Thus making legal.

C pointers and arrays: [Warning] assignment makes pointer from integer without a cast

In this case a[4] is the 5th integer in the array a, ap is a pointer to integer, so you are assigning an integer to a pointer and that’s the warning.So ap now holds 45 and when you try to de-reference it (by doing *ap) you are trying to access a memory at address 45, which is an invalid address, so your program crashes. You should do ap … Read more

How to go from fopen to fopen_s

fopen_s is a “secure” variant of fopen with a few extra options for the mode string and a different method for returning the stream pointer and the error code. It was invented by Microsoft and made its way into the C Standard: it is documented in annex K.3.5.2.2 of the most recent draft of the C11 Standard. Of course it … Read more

How do I use valgrind to find memory leaks?

Try this: valgrind –leak-check=full -v ./your_program As long as valgrind is installed it will go through your program and tell you what’s wrong. It can give you pointers and approximate places where your leaks may be found. If you’re segfault’ing, try running it through gdb.

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