Thread: Make a mess

  1. #1
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218

    Make a mess

    How about a little group project for some light entertainment? This project has no specific aim, and anyone can contribute by adding/changing whatever they like, as long as it meets the rules. To do so take the most recent version, add something to it, then post it back.

    The rules are simple:
    1) Each new revision must compile with g++, but may have bugs in it (deliberate or not).
    2) Only standard libraries can be included.
    3) New versions should describe roughly what was changed.

    I'm sure that between the lot of us we can come up with something amazing. I attached something to start off with.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    C or C++?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Code in whatever will work, although probably no ASM unless its going to on all PCs.

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    An update of your man struct, it really needed it:
    Code:
    struct DATE {
       WORD year, month, day, hour, minute, second, millisecond;
    };
    
    typedef struct {   // version 2
       pman mother, father;
       BOOL sex;
       char *name;
       double x, y;
       DATE birth;
    } man, *pman;

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No, no, what you really need is:
    Code:
    	man* people[100]; 
    	people[0] = MakeMan("Bob");
    	printf("Hello I am %s ", people[0]->name);
    	free(people[0]);
    	getchar();
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Yarin View Post
    typedef struct { // version 2
    pman mother, father;
    mother is a pointer to a man?

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Removing the disgusting pointer typedef...
    Code:
    struct DATE {
       WORD year, month, day, hour, minute, second, millisecond;
    };
    
    typedef struct {   // version 2
       pman mother, father;
       BOOL sex;
       char *name;
       double x, y;
       DATE birth;
    } man;
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    >> mother is a pointer to a man?
    yes, the man struct is just a human.

  9. #9
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    dave, if you get rid of code, you should add new stuff to take it's place.

    another update:
    Code:
    ... // code needs to be made for the memory & ai
    
    struct DATE {
       WORD year, month, day, hour, minute, second, millisecond;
    };
    
    class HUMAN {   // version 3
       // family
       PHUMAN mother, father;
       PHUMAN *child;
       DWORD children;
       // specifiers
       BOOL sex;
       char *name;
       double x, y, z;
       DATE birth;
       // more
       BRAIN mem;
    };
    
    typedef PHUMAN *HUMAN;   // I like typedefs! >:(

  10. #10
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    >dave, if you get rid of code, you should add new stuff to take it's place.
    Naw. To quote Prelude: "My best code is written with the delete key."
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I hate pointer typedefs/defines. They only make the code harder to read.
    And gender should be an enum!
    And no char*, only std::string!
    What's missing is smart pointers, though.

    Code:
    struct DATE
    {
    	WORD year;
    	WORD month;
    	WORD day;
    	WORD hour;
    	WORD minute;
    	WORD second;
    	WORD millisecond;
    };
    
    enum eGender
    {
    	Female,
    	Male
    };
    
    struct HUMAN
    {   // version 3
    	// family
    	HUMAN* mother;
    	HUMAN* father;
    	HUMAN* child;
    	DWORD children;
    	// specifiers
    	eGender gender;
    	std::string name;
    	double x, y, z;
    	DATE birth;
    	// more
    	BRAIN mem;
    };
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Yarin:
    Small alterations can be left in comments, like dave's, and elysia's.

    If you are going to change the structures, you should alter the rest of the code to facilitate this. For example, whats BRAIN? If you simply dump your structs in, it will mangle the prog. Not that theres much to get mangled yet, but maybe post something that will compile?

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Code:
    class BRAIN
    {
    public:
    	BRAIN(): bHasBrain(false) { }
    	bool bHasBrain;
    };
    
    struct DATE
    {
    	WORD year;
    	WORD month;
    	WORD day;
    	WORD hour;
    	WORD minute;
    	WORD second;
    	WORD millisecond;
    };
    
    enum eGender
    {
    	Female,
    	Male
    };
    
    struct HUMAN
    {   // version 3
    	// family
    	HUMAN* mother;
    	HUMAN* father;
    	HUMAN* child;
    	DWORD children;
    	// specifiers
    	eGender gender;
    	std::string name;
    	double x, y, z;
    	DATE birth;
    	// more
    	BRAIN mem;
    };
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    And here I was just going to do a stupid little die roll, and make "Bob" walk somewhere.

  15. #15
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Much better.
    Code:
    class BRAIN
    {
       public:
          BRAIN(): bHasBrain(false) { }
          bool bHasBrain;
    };
    
    struct DATE
    {
       WORD year;
       WORD month;
       WORD day;
       WORD hour;
       WORD minute;
       WORD second;
       WORD millisecond;
    };
    
    enum gender
    {
       female,
       male
    };
    
    struct HUMAN
    {
       // version 3
       // family
       HUMAN *mother;
       HUMAN *father;
       HUMAN **kid;
       DWORD kids;
       // specifiers
       gender sex;
       char *name;
       double x, y, z;
       DATE birth;
       // more
       BRAIN mem;
    };
    Code + tabs = unreadable hash of mashed tomato juice!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  2. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 12:43 PM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM
  5. Replies: 6
    Last Post: 04-20-2002, 06:35 PM