C/C++

Member

vivien_maggio

by vivien_maggio , in category: C/C++ , 2 months ago
no answers

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);
		}
	}

Member

kian

by kian , in category: C/C++ , 2 months ago
no answers

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;
	}
};


Member

vivien_maggio

by vivien_maggio , in category: C/C++ , 2 months ago
no answers

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);


Member

erica

by erica , in category: C/C++ , 2 months ago
no answers

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; }
}

C/C++ Bad Code Examples