Thread: learning c help need for a dummy

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    1

    learning c help need for a dummy

    hi i am new to this forum and this being my last resort for help because y i am learning how to program in c but very very slowly. i really need help .

    this is my code .all i am trying to do is call a void function from my swtich statment to print a sentence get random numbers . can someone please point me in the right direction.

    using mircale c to compile. thats my error ?

    .c:\program files\miracle c\assigment4exper.c: line 37: Parse Error, expecting `SEP'
    'void getnum() { printf("1 get Random numbers\n")'
    aborting compile

    Code:
      #include <stdio.h>
    
    void dispMenu(void);
    void getnum(void);
    
    
    void main()
    {
     
     int select;
     
    do{
        dispMenu();
        
        printf("Please enter a selection: ");
        scanf("%d",&select);
        
        switch(select)
      {
         case 1: getnum();
                 break;
         case 2: disNumbers();
                 break;
        default:  printf("failed\n");
     }
    }while(select>=1&&select<=2);
     getch();
    }
    
     
    void dispMenu()
    {
     void getnum() 
     {
      printf("1  get Random numbers\n"); 
     }
    Last edited by borz; 04-01-2006 at 02:38 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > using mircale c to compile. thats my error ?
    Yes, miracle C is a piece of .........
    Search the board for everyone else who's come unstuck with that rubbish compiler.

    Get dev-c++, which as well as being really free (as opposed to nagware), it smashes miracle C into the ground

    > void main()
    main returns an int

    > void getnum
    You're declaring this function inside dispMenu, check the positioning of your braces.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Machine Learning with Lego Mindstorms
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-30-2009, 02:34 PM
  2. Circular doubly linked list with dummy header
    By mag_chan in forum C Programming
    Replies: 5
    Last Post: 10-31-2005, 08:44 AM
  3. Need Help On a Simple Bank Program
    By oobootsy1 in forum C# Programming
    Replies: 9
    Last Post: 08-08-2005, 10:51 AM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM
  5. how to obtain first character of every other word
    By archie in forum C++ Programming
    Replies: 8
    Last Post: 02-18-2002, 01:58 PM