Should I include or in C++ programs?

Consider the following programs: Sample 1: #include<stdio.h> int main() { printf(“Hello World”); return 0; } Sample 2: #include<cstdio> int main() { printf(“Hello World”); return 0; } Both work as expected. So which usage is more appropriate? The answer is: Neither! Surprised? Read on. The C++ Standard library provides all standard C headers for compatibility reason, … Read more

gcc/g++: “No such file or directory”

Your compiler just tried to compile the file named foo.cc. Upon hitting line number line, the compiler finds: #include “bar” or #include <bar> The compiler then tries to find that file. For this, it uses a set of directories to look into, but within this set, there is no file bar. For an explanation of … Read more

Semantics of flags on basic_ios

There are three flags that indicate error state: badbit means something has gone very wrong with the stream. It might be a buffer error or an error in whatever is feeding data to the stream. If this flag is set, it’s likely that you aren’t going to be using the stream anymore. failbit means that … Read more