brilliant code

This is a discussion on brilliant code within the A Brief History of Cprogramming.com forums, part of the Community Boards category; My most brilliant code, swapping two variables without having a 3rd temporary variable! Code: #define swap(a,b) a ^= b ^= ...

  1. #16
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    My most brilliant code, swapping two variables without having a 3rd temporary variable!

    Code:
    #define swap(a,b)      a ^= b ^= a ^= b
    My Website

    "Circular logic is good because it is."

  2. #17
    Shadow12345
    Guest
    Code:
    #include <vector>
    #include <windows.h>
    #include <conio.h>
    #include <istream>
    using namespace std;
    int main() {
    cout << "See how long it takes you to figure out why this won't work " << endl;
    return 0;
    }

  3. #18
    Shadow12345
    Guest
    what does
    ^=
    mean, i haven't seen that before

  4. #19
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    XOR+equals
    PHP and XML
    Let's talk about SAX

  5. #20
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    Originally posted by Shadow12345
    Code:
    #include <vector>
    #include <windows.h>
    #include <conio.h>
    #include <istream>
    using namespace std;
    int main() {
    cout << "See how long it takes you to figure out why this won't work " << endl;
    return 0;
    }
    #include <istream>

    no output streams, that was easy
    PHP and XML
    Let's talk about SAX

  6. #21
    Shadow12345
    Guest
    Code:
    #include <iostream>
    using namespace std;
    
    int main() {
    cout << "Now you will be really perplexed as to why this one wont' work" << endl;
    return 0;
    }

  7. #22
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    i may be drunk but i did notice the missing std:: namespace declarations on yor cout and endl;s
    PHP and XML
    Let's talk about SAX

  8. #23
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    worked on my compiler...retard...

  9. #24
    Shadow12345
    Guest
    I don't think I have ever written brilliant code. I am at the point that whenever I have a lot of '*' in my code, and do a lot with filestreams, I think I am brilliant, but that is only the newbie part of me that remembers seeing the bigger more mature programmers using '*'s and filestreams.

  10. #25
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    yeah pointers are hard
    once you get how to use them it's great...
    for a newb you've gogtat lot of posts dude
    PHP and XML
    Let's talk about SAX

  11. #26
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Originally posted by Shadow12345
    Code:
    #include <iostream>
    using namespace std;
    
    int main() {
    cout << "Now you will be really perplexed as to why this one wont' work" << endl;
    return 0;
    }
    because it works

  12. #27
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    ' should be \'
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  13. #28
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Originally posted by Sang-drax
    ' should be \'
    First I thought that, but when I compiled and run the program it was fine, using MSVC++!
    Maybe because it's a string, but if you want to put " you will havetouse \", maybe because there is a " before it!
    if you are trying to write cout << '\''; you should use \'
    If you know why please tell me.

  14. #29
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    You can use both notations (with or without the \) for a single quote or question mark in a string.

  15. #30
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Most brilliant code? How about the worlds smallest program:
    Code:
     
    Unfortunately, it's not 100% portable.

    -Prelude
    My best code is written with the delete key.

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21