Make a mess

This is a discussion on Make a mess within the A Brief History of Cprogramming.com forums, part of the Community Boards category; How about a little group project for some light entertainment? This project has no specific aim, and anyone can contribute ...

  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.
    Attached Files Attached Files

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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
    1,608
    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;
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    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,006
    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
    1,608
    >> mother is a pointer to a man?
    yes, the man struct is just a human.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  9. #9
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,608
    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! >:(
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  10. #10
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    >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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,667
    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
    1,608
    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!
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

Page 1 of 2 12 LastLast
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, 08: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

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