Whats the news about enum?

This is a discussion on Whats the news about enum? within the C Programming forums, part of the General Programming Boards category; I have no clue according to this text how to get this to operate. huh? I know i need some ...

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Question Whats the news about enum?

    I have no clue according to this text how to get this to operate. huh?
    I know i need some kind of starting poiny and what to be printed onto the screen and a return. My question is how do i get it to perform the next day operation so how do i get it to start, please.
    Take a gander that the first few lines then you can shred this program apart anyway you like it. I hope someone can give me a better example to get this program running.

    #include<stdio.h>

    int main(void)
    {
    day find_next_day(day d);
    printf("%s", next_day);
    return 0;
    {



    enum day {sun, mon, tue, wed, thu, fri, sat};

    typedef enum day day;

    day find_next_day(day d)
    {
    day next_day;

    switch (d) {
    case sun:
    next_day = mon;
    break;
    case mon:
    next_day = tue;
    break;
    case tue:
    next_day = wed;
    break;
    case wed:
    next_day = thu;
    break;
    case thu:
    next_day = fri;
    break;
    case fri:
    next_day = sat;
    break;
    }
    return next_day;
    }

    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    A different version of code, showing how to increment through the days of the week:
    Code:
    #include <stdio.h>
    
    int main(void)
    {
    	enum day {sun, mon, tue, wed, thu, fri, sat, totaldays}; 
    	enum day Today;
    	int i;
    	
    	for (i = 0, Today = sun; i < 20; i++)
    	{
    		printf ("Today is daynum %d\n", Today);
    		Today = (Today+1) % totaldays;
    	}
    	
    	return 0;
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A basic question on enum
    By MasterM in forum C++ Programming
    Replies: 2
    Last Post: 06-12-2009, 10:16 PM
  2. "sorting news" assignment
    By prljavibluzer in forum C Programming
    Replies: 7
    Last Post: 02-06-2008, 06:45 AM
  3. enum [tag] [: type] Is this non-standard?
    By HyperShadow in forum C++ Programming
    Replies: 2
    Last Post: 12-09-2007, 10:29 PM
  4. Conflicting enum issue
    By 7force in forum C Programming
    Replies: 1
    Last Post: 07-05-2006, 04:51 AM
  5. Switch case and enum help
    By SomeCrazyGuy in forum C++ Programming
    Replies: 9
    Last Post: 04-21-2005, 09:53 PM

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