Short C++ Notes on check if a file exists, string concatenation, vector
- To check if a file exists, the best way is to use stat, however, sometimes this can be problematic (some say when a file is larger than 2 GB). I haven’t run into that particular problem yet.
- Good post http://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c . I specially like the listing of all 4 methods and benchmark them.
- Concatenate string <string.h> and convert integer to string
- It turns out that C++ string utility is pretty useful. You can simply do A + B to concatenate two string.
- However, to use a char* type, you need to do string.c_str() with <cstring> included.
- To convert an integer to string, try this trick
- Vector with push back is very slow, try using an integer array with a dynamic index.