Creating a class scheduler

This is a discussion on Creating a class scheduler within the C Programming forums, part of the General Programming Boards category; Hello to everyone! I'm trying to code a basic class scheduler, which checks if the time slot chosen by a ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    7

    Creating a class scheduler

    Hello to everyone! I'm trying to code a basic class scheduler, which checks if the time slot chosen by a the user is already occupied or not, I'm having trouble constructing a 12x6 table wherein I can print on top "monday,tuesday,wednesday,thursday" and on the side the time slots like 7:30-8:20, 8:20-9:10,etc. . .

    I've successfully created a table, I can't think of how to print inside the table

    Code:
    #include<stdio.h>
    
    char board[12][6];
    int main()
    {
        
       
       
    int x;
    int y;
        for(x=0; x<12; x++)
        {
                 for(y=0;y<6;y++)
                 {
           printf("\t\t\t %c | %c | %c | %c | %c | %c",board[x][y],
           board[x][y], board [x][y], board [x][y], board [x][y], board [x][y]);
           
            printf("\n\t\t\t---+---+---+---+---+---\n");
       
        }
           
        }
        getchar();
        getchar();
        return 0;
    }

    here is my code.

  2. #2
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    What's the problem in this code???
    I mean any error or output is not formatted?

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    Quote Originally Posted by Mr.777 View Post
    What's the problem in this code???
    I mean any error or output is not formatted?
    that's my initial code. I don't know how to place words like "monday,tuesday" in the spaces of the table.

  4. #4
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Do
    Code:
    strcpy(board[x][y],"Monday");
    and so on...

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    Quote Originally Posted by Mr.777 View Post
    Do
    Code:
    strcpy(board[x][y],"Monday");
    and so on...
    oh so I also do that if I also want to enter the time slots on the side?

  6. #6
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Sure as you are handling them as string....

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    question,where do I place the
    Code:
    strcpy(board[x][y],"Monday");

    sorry, I'm getting errors.

  8. #8
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    What errors?

  9. #9
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    Quote Originally Posted by Mr.777 View Post
    What errors?
    it says "subscripted value is neither array nor pointer" :-?

  10. #10
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Not even possible..... Then there will be some problem with your code... Post your code here....

  11. #11
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    here's the new code

    Code:
    #include<stdio.h>
    
    char board[12][6];
    int main()
    {
        
       
       
    int x;
    int y;
        for(x=0; x<12; x++)
        {
                 for(y=0;y<6;y++)
                 {
           printf("\t\t\t %c | %c | %c | %c | %c | %c",board[x][y],
           board[x][y], board [x][y], board [x][y], board [x][y], board [x][y]);
           
            printf("\n\t\t\t---+---+---+---+---+---\n");
       
        }
           
        } strcpy(board[x][y],"Monday");
        getchar();
        getchar();
        return 0;
    }

  12. #12
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    I think you should better follow the book or some tutorials first.... But more than learning, you should think, what you are doing above.......
    1. Include header file......
    Code:
    #include<string.h>
    2. Do,
    Code:
    strcpy(board[your_Index_Here],"Monday");
    Note:
    Now you think, where to copy these days values in your program.....

    And just provide with the row index, not the column index while copying days into the array.

  13. #13
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    Quote Originally Posted by Mr.777 View Post
    I think you should better follow the book or some tutorials first.... But more than learning, you should think, what you are doing above.......
    1. Include header file......
    Code:
    #include<string.h>
    2. Do,
    Code:
    strcpy(board[your_Index_Here],"Monday");
    Note:
    Now you think, where to copy these days values in your program.....

    And just provide with the row index, not the column index while copying days into the array.
    where exactly do I put the
    Code:
    strcpy(board[your_Index_Here],"Monday");
    ?
    I've been reviewing the stuff our teacher had given me and I tried them all but they still won't output.

  14. #14
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    For the days of the week, I'd suggest a small array:

    Code:
    char days={"", "Sunday","Monday","Tuesday", "Wednesday", "Thursday","Friday","Saturday"};
    and now you can easily remember and use the number of the day of the week, inside your program:
    Code:
    for(i=1;i<8;i++)
      printf("\n %9s",days[i]); 
    printf("/n ");
    for(i=0;i<70;i++)
      putchar('=');
    You need the strings printed out inside a fixed field, to easily "mark up" your schedule. I believe 9 for the string, and one for the space, is about right, since it's an easy 10 char wide, in total.

    So if I want to mark something in Tuesday's column, I know that column starts at (10 * 3).

    If you want something with more columns, you may want to use the days 3 letter abbreviation, instead of the full day's word.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a thread in a class - C++
    By rag84dec in forum Windows Programming
    Replies: 1
    Last Post: 08-07-2009, 04:52 AM
  2. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 02:03 AM
  3. Creating threads from a class
    By Niara in forum C++ Programming
    Replies: 2
    Last Post: 06-02-2006, 04:52 PM
  4. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 03:33 PM
  5. Creating a string class
    By incognito in forum C++ Programming
    Replies: 2
    Last Post: 01-19-2002, 05:40 PM

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