#21
|
|||
|
One night I was out drinking. Being a model student, I decided to work on a c++ project when I got home. That night, I went to bed proud of all the work I accomplished. The next morning, I spent about 2 hours fixing all the typos and dumb code that I wrote the night before. That's when I decided that any language which doesn't allow you to code drunk is a piece of shit that overcomplicates simple tasks.
__________________
Uuur - Your favorite Master +1 cleric <LifeAlert> Rockwell - Your favorite 30 virgin <Aspen and Rockwell> | ||
|
#22
|
|||
|
Step 1: Buy beer.
Step 2: Get drunk. Step 3: Write everything in Pseudocode. Step 4: Translate to regular code while sober. Step 5: ..... Step 6: Profit Or... experiment more with Ballmer's Peak | ||
|
#24
|
|||
|
Angwe is back in business
__________________
| ||
|
#25
|
|||
|
here's a simple way to do part 1 without the need for an array
Code:
#include <stdlib.h> #include <iostream> #include <stdio.h> using namespace std; int main() { int count, min, max, total; count=0; total=0; cout << "Please enter 5 numbers seperated by a space\n"; while ( count < 5 ) { int number; cin >> number; count++; if ( 1 == count ) { min=number; max=number; } else { if ( number < min ) min = number; if ( number > max ) max = number; } total += number; } cout << " Lowest: " << min << endl << "Highest: " << max << endl << "Average: " << total/5 << endl; system("pause"); return 0; } | ||
|
#26
|
|||
|
Dangling Pointer = Fallacy
So I have never used smart/auto pointers or seen them used in any production code. One of the big woops about them is that when you copy addresses it nulls the first pointer so you can't dangle it. So I was like man let's see if its a big woop after all.
PHP Code:
Code:
r00t@wutdo:~/dangling$ g++ -g -O0 -fno-inline main.cpp r00t@wutdo:~/dangling$ ./a.out 0x24d5010 = 420 Segmentation fault | ||
Last edited by Truth; 02-24-2012 at 03:57 PM..
Reason: nerdalert
|
|
|
|