How to catch exceptions in C++ π
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } |
Is anyone else see the bug here C++?? π
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include <iostream> #include <vector> template <typename T> struct Vec { T x, y; Vec& operator /=(const T& d) { x /= d; y /= d; return *this; } }; |
Another way to copy files over
1 2 3 4 5 6 7 8 9 |
var src = "c:\src"; var dest = "c:\dest"; var cmp = CompressionLevel.NoCompression; var zip = source_folder + ".zip"; ZipFile.CreateFromDirectory(src, zip, cmp, includeBaseDirectory: false); ZipFile.ExtractToDirectory(zip, dest_folder); File.Delete(zip); |
Nice function to get a random number in C
1 2 3 4 5 6 7 8 |
void init_rand(unsigned long int x) { int i; Q[0] = x; Q[1] = x + PHI; Q[2] = x + PHI + PHI; for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; } } |