Results 1 to 3 of 3

Thread: C++ program Help

  1. #1
    Platinum+ Member
    Join Date
    Nov 2004
    Location
    India
    Posts
    684

    C++ program Help

    Someone I know has this trouble with the program (code below):

    I am getting the following error
    Call of nonfunction
    in the line
    SET_MODE(TEXT_MODE);
    Code:
    #include<stdio.h>
    #include<iostream.h>
    #include<dos.h>
    #include<conio.h>
    #include<graphics.h>
    #include<fstream.h>
    #include<process.h>
    #include<mem.h>
    #define  o  outtextxy
    #define  s  setcolor
    #define  se  setfillstyle
    #define SET_MODE 0x00
    #define TEXT_MODE 0x03
    
    			/* PERSONAL TELEPHONE DIRECTORY
    			IN BORLAND C++ 3.1
    			BY
    			ABHISHEK DEY DAS */
    
    
    void addy()
    {
    	//Function that adds new records
    	SET_MODE(TEXT_MODE);
    	clrscr();
    	char name[99];
    	char htele[30];
    	char otele[30];
    	char mtele[30];
    	char ftele[30];
    	char addy[999];
    	char email[20];
    
    	cout<<"Enter name: ";
    	gets(name);
    	cout<<"Enter address: ";
    	gets(addy);
    	cout<<"Enter home telephone number: ";
    	gets(htele);
    	cout<<"Enter office telephone number: ";
    	gets(otele);
    	cout<<"Enter mobile number: ";
    	gets(mtele);
    	cout<<"Enter FAX number: ";
    	gets(ftele);
    	cout<<"Enter email ID: ";
    	gets(email);
    };
    
    void eddy()
    {
    	//Function that edits existing records
    };
    
    void del()
    {
    	//Function that delets desired records
    };
    
    void sea()
    {
    	//Function that searches for records
    };
    
    void exp()
    {
    	//Function that exports records
    };
    
    
    void men()
    {
    	  //Initialising the graphics screen
    
           int gd=DETECT,gm,maxx,maxy,j,m,i,x=600,y=450;
           initgraph(&gd,&gm,"d:\\tc\\bgi");
    
           //Variable declarations
           char men1;
    
           maxx=getmaxx();
           maxy=getmaxy();
    
    
          //Printing out the main menu screen
    
          s(MAGENTA);
          rectangle(20,20,625,450);
          settextstyle(1,HORIZ_DIR,2);
          s(2);
          o(130,150,"PERSONAL   TELEPHONE   DIRECTORY");
          sound(700);
          delay(400);
          nosound();
    
          s(CYAN);
          settextstyle(3,HORIZ_DIR,2);
          o(140,200,"Hit 1 to add new records");
          o(140,220,"Hit 2 to edit records");
          o(140,240,"Hit 3 to delete records");
          o(140,260,"Hit 4 to search for records");
          o(140,280,"Hit 5 to export records");
          o(140,300,"Hit 6 to exit");
    
    
          men1=getch();
    
         if (men1=='1')
         { addy(); }
         else if (men1=='2')
         { eddy(); }
         else if (men1=='3')
         { del(); }
         else if (men1=='4')
         { sea(); }
         else if (men1=='5')
         { exp(); }
         else
         {   exit(1); }
    
    };
    
    
    void main()
    {
       clrscr();
    
    
      men();
    
    };
    Can anyone help?

  2. #2
    Banned
    Join Date
    Apr 2002
    Posts
    109
    The line:
    #define SET_MODE 0x00
    is a simple macro substitution, which causes the preprocessor to replace all occurrences of SET_MODE with 0x00
    However, SET_MODE(TEXT_MODE); is a function call, passing the parameter TEXT_MODE to the function SET_MODE(), which, as stated, is clearly not a function. Using macro substitution, the preprocessor will expand
    SET_MODE(TEXT_MODE);
    to:
    0x00(0x03);
    Clearly not what is wanted...

  3. #3
    Platinum+ Member
    Join Date
    Nov 2004
    Location
    India
    Posts
    684
    Thanks Nikto

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •