How to Compare 2 Character Arrays [duplicate]

but I read somewhere else that I couldnt do test[i] == test2[i] in C. That would be really painful to compare character-by-character like that. As you want to compare two character arrays (strings) here, you should use strcmp instead: Edit: There is no need to specify the size when you initialise the character arrays. This … Read more

Categories C Tags

Whats the difference between UInt8 and uint8_t

In C99 the available basic integer types (the ones without _t) were deemed insufficient, because their actual sizes may vary across different systems. So, the C99 standard includes definitions of several new integer types to enhance the portability of programs. The new types are especially useful in embedded environments. All of the new types are … Read more

Graphics library in C

To plot 2D and 3D graphs in C I would recommend the library DISLIN. You can see examples here or there. The code is pretty easy to use and gives nice results.

meaning of &variable (passed to function)

func being some arbitrary user defined function It couldn’t be “arbitrary” – it must take a pointer to int or a void* in order for the call to be legal. This ampersand is the “take address” operator. It passes func the address of a, so that the func could, for example, modify it: If your … Read more

Usage of \b and \r in C

The characters will get send just like that to the underlying output device (in your case probably a terminal emulator). It is up to the terminal’s implementation then how those characters get actually displayed. For example, a bell (\a) could trigger a beep sound on some terminals, a flash of the screen on others, or … Read more

Categories C Tags

fgetc(stdin) in a loop is producing strange behaviour

Terminals tend to be line-buffered, meaning that stream contents are accessible on a line-by-line basis. So, when fgetc starts reading from STDIN, it’s reading a full line, which includes the newline character that ended that line. That’s the second character you’re reading. As for fflush, that’s for flushing output buffers, not input buffers. So, what … Read more

Using pointer to char array, values in that array can be accessed?

When you want to access an element, you have to first dereference your pointer, and then index the element you want (which is also dereferncing). i.e. you need to do: printf(“\nvalue:%c”, (*ptr)[0]); , which is the same as *((*ptr)+0) Note that working with pointer to arrays are not very common in C. instead, one just use a … Read more

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