Thread: Linking pages problem

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    10

    Linking pages problem

    I cant seem to link my "time page" to link from my menu what the problem ?
    Code:
    #include <stdio.h>
    #include<stdlib.h>
    int menu(void);
    int distance(void);
    int Time(void);
    int sw;
    int main()
    {
    menu();
    }
    
    
    int menu()
    {
    system("cls");
    
    printf(" Please selcet a number which represents a catagory !\n");
    printf(" 1.Weight\n");
    printf(" 2.Measurement\n");
    printf(" 3.Distance\n");
    printf(" 4.Time \n ");
    sw=getch();
    sw=sw-'0';
    switch(sw)
    {
    case 1:
    //code....
    break;
    
    
    case 2:
    //...
    break;
    
    
    case 3:
    distance();
    break;
    
    
    case 4:
    time();
    break;
    
    
    default:
    menu();
    break;
    }
    }
    int distance()
    {
    system("cls");
    printf(" 1.Mile's to kilometre's\n");
    printf(" 2.Kilomere's to mile's\n");
    printf(" 3.Back to the Main menu\n");
    sw=getch();
    sw=sw-'0';
    switch(sw)
    {
    case 1:
    //code...
    break;
    
    
    case 2:
    //code...
    break;
    
    
    case 3:
    main();
    break;
    
    
    default:
    distance();
    break;
    }
    }
    int Time()
    {
    system("cls");
    printf(" 1.test\n");
    printf(" 2.test\n");
    printf(" 3.Back to the Main menu\n");
    sw=getch();
    sw=sw-'0';
    switch(sw)
    {
    case 1:
    //code...
    break;
    
    
    case 2:
    //code...
    break;
    
    
    case 3:
    main();
    break;
    
    
    default:
    Time();
    break;
    }
    }
    Cant seem to find out what I have done wrong

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Use a CAPITAL T... you have a lower case T in main

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    10
    I have done that and still have the same problem

  4. #4
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    I see that you call main???? Dont call main in your functions. You might want to read up a little more on function tutorial on this site. When you have a return type like int in your function, it expects you to return an integer. ex)
    Code:
    int Time(void)
    {
    int variable=3;
    return variable;
    }

  5. #5
    Registered User
    Join Date
    Sep 2012
    Posts
    10
    Could you show me within the code it self to see what i have done wrong by any chance ?

  6. #6
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Take things slow first. I dont think that right now you should be calling a function in itself. Example you call time within time. That is considered recursion and I doubt that is what you mean to do at this point. Just remember that whenever you want to go back to main from your function, you have to use the keyword 'return'. Fix those parts first then re post your new code. Also use getchar instead of getch.
    Last edited by camel-man; 10-31-2012 at 09:33 PM.

  7. #7
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Please indent your code. Many people here will just ignore you if don't care about posting readable code.

    Bye, Andreas

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with linking .LIB
    By lapo in forum C Programming
    Replies: 2
    Last Post: 10-31-2007, 03:41 AM
  2. Odd Problem with Linking
    By jamez05 in forum C++ Programming
    Replies: 6
    Last Post: 09-21-2005, 01:49 PM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  4. Linking problem...
    By BrianK in forum C++ Programming
    Replies: 2
    Last Post: 10-08-2002, 04:13 PM
  5. Hve a problem linking
    By cooleeze in forum C++ Programming
    Replies: 7
    Last Post: 11-23-2001, 02:43 PM