Tag Archive

The following is a list of all entries tagged with C/C++:

Nothing Could Fail in C

Best comment of the C programming language ever!
via:reddit
Here is the whole story:

Going back to C
by buddhabrot
When I was 12 someone gave me a Metrowerks IDE to learn programming on my mac. I learned a lot with it, and got programming in C. I never really wrote a large program in it, only things like ROM [...]


Patch to Broadcom 802.11 Linux STA driver for Kernel 2.6.27

Update 2009-01-04: As Jose mentioned, the latest driver (ver. 5.10.27.12) no longer needs this patch!
If you have problem to compile Broadcom 802.11 Linux STA driver (version 5.10.27.6) on Kernel 2.6.27 and get error message like the following:

/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c: In function ‘wl_iw_get_scan’:
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: warning: passing argument 1 of ‘iwe_stream_add_event’ from incompatible pointer type
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: warning: passing argument 3 of [...]


How To Prevent Creating Objects On Heap

Yesterday I saw a C++ interview question that was asking the interviewees to prevent the clients from creating objects on heap. That is, you write a class and your class users can’t use new to create an object.
Here is my solution:

class Foo
{
public:
Foo(const Foo& f) {}
static Foo getAnInstance()
[...]


Solving Cyclic Dependencies Is Hard

I am a C/C++ beginner but I’d been already taught that dependency cycles are generally evil since it’s very hard to solve. I haven’t realized how hard the problem is before, because all the works I’ve done are “one file” programs or I can just simply throw all the files into a single gcc/g++ command.
However, [...]


Weird Hex Output

In C++, to output and integer in hex, I’d been taught to do this:
cout << hex << an_integer;
And if I want to show “0x” before the value, I need to do the following:

cout.setf(ios::showbase);
cout << hex << an_integer;

The above code works well for either positive or negative integers, but not the value ZERO. If I run [...]