Why use conio.h?

The conio.h header is specific to Turbo C, which predates the earliest C standard by several years. It contains routines that are specific to the DOS command line. One function here that’s frequently used is getch, which allows reading one character at a time without having to press the Enter key. It also contains gotoxy which allows placing … Read more

What exactly is nullptr?

How is it a keyword and an instance of a type? This isn’t surprising. Both true and false are keywords and as literals they have a type ( bool ). nullptr is a pointer literal of type std::nullptr_t, and it’s a prvalue (you cannot take the address of it using &). 4.10 about pointer conversion says that a prvalue of type std::nullptr_t is a null pointer constant, and that an … Read more

Convert char to int in C and C++

Depends on what you want to do: to read the value as an ascii code, you can write to convert the character ‘0’ -> 0, ‘1’ -> 1, etc, you can write Explanation:a – ‘0’ is equivalent to ((int)a) – ((int)’0′), which means the ascii values of the characters are subtracted from each other. Since 0 comes directly before 1 in the ascii … Read more

Good input validation loop using cin – C++

I’m not a huge fan of turning on exceptions for iostreams. I/O errors aren’t exceptional enough, in that errors are often very likely. I prefer only to use exceptions for less frequent error conditions. The code isn’t bad, but skipping 80 characters is a bit arbitrary, and the error variable isn’t necessary if you fiddle … Read more

Passing an array by reference

It’s a syntax for array references – you need to use (&array) to clarify to the compiler that you want a reference to an array, rather than the (invalid) array of references int & array[100];. EDIT: Some clarification. These three are different ways of declaring the same function. They’re all treated as taking an int * parameter, you can pass … Read more

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