Difference between int32, int, int32_t, int8 and int8_t

Between int32 and int32_t, (and likewise between int8 and int8_t) the difference is pretty simple: the C standard defines int8_t and int32_t, but does not define anything named int8 or int32 — the latter (if they exist at all) is probably from some other header or library (most likely predates the addition of int8_t and int32_t in C99). Plain int is quite a bit different from the others. Where int8_t and int32_t each have a specified size, int can be … Read more

How do I create an array of strings in C?

If you don’t want to change the strings, then you could simply do When you do it like this you will allocate an array of two pointers to const char. These pointers will then be set to the addresses of the static strings “blah” and “hmm”. If you do want to be able to change the actual string content, … Read more

Eclipse C++ : “Program “g++” not found in PATH”

Today I have bumped into this problem and solved it in the following way. I pressed “Reset defaults” button everywhere I could find it in Eclipse settings (for example, Preferences/C++/Build/Settings/Discovery). After that the error disappeared and the code compiled successfully.

Should I learn C before learning C++?

There is no need to learn C before learning C++. They are different languages. It is a common misconception that C++ is in some way dependent on C and not a fully specified language on its own. Just because C++ shares a lot of the same syntax and a lot of the same semantics, does … Read more

Why do I get clang: error: linker command failed with exit code 1?

Why do I get clang: error: linker command failed with exit code 1? You just declared the function. There is not any definition in code. At the time of linking process , compiler(here clang) cannot link power function to its definition so linker throws the error in this kind of situation. If you define Then linker can … Read more

Categories C Tags

Why does the arrow (->) operator in C exist?

I’ll interpret your question as two questions: 1) why -> even exists, and 2) why . does not automatically dereference the pointer. Answers to both questions have historical roots. Why does -> even exist? In one of the very first versions of C language (which I will refer as CRM for “C Reference Manual“, which came with 6th Edition Unix in … Read more

How I can print to stderr in C?

The syntax is almost the same as printf. With printf you give the string format and its contents ie: With fprintf it is the same, except now you are also specifying the place to print to: Or in your case:

Why do I get an assertion failure?

My guess is that the file is failing to open, and you’re still passing it to fgets. Your if(rd==NULL) doesn’t stop execution of the fgets if it’s null, it just prints out a message and continues with execution. Some very basic errorr handling:

Map like structure in C: use int and struct to determine a value

You’ll probably have to make your own structure. The C Programming Language by Kernighan and Ritchie has an example of making an associate map in c, and what I’ll detail below is based on what I remember from that. Basically you’ll need a struct Map that contains struct Key and struct Value. struct Key contains elements that determine the value (in your case 2 … Read more

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