Header File Question(s)

This is a discussion on Header File Question(s) within the C++ Programming forums, part of the General Programming Boards category; I would like to include the time.h header file to be able to get the system date and time to ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    Header File Question(s)

    I would like to include the time.h header file to be able to get the system date and time to appear on some menus I am creating, but it doesn't seem to include the features I want, (I am using the one that is included with Dev-C++ version 4). My question is can I find another version of this header and use it for this program? If I do, is there anything special I have to do to be able to use it?

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    The problem is that header files aren't enough. All they do is tell you what functions are avialable but they don't provide the functions themselves. For that you'll need the library file and then you'll have to link in that file.

    Now if you explain what you want to do then maybe we can point you in the right direction.

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    Header File Question(s)

    I am trying to use the ideas presented to me in a posting that was posted last night, but the ideas are not working. I will include my program so that it can be reviewed here to see what I may be doing wrong.

  4. #4
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    Header File Question(s)

    Here is a sample of the program:


    Code:
    #include <time.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string>
    #include <iostream>
    #include <fstream>
    
      char  Menu_Opt[4];   		/* Menu Option                 */
       char *ctime( const time_t *time );
       float Org_Curr_Amt = 0.00;	/* Original Currency Amount    */
       float New_Curr_Amt = 0.00;	/* New Currency Amount         */
       char  Currency_Desc[24][100] = {"American Dollar (USD)", "Australian Dollar (AUD)",
    	  "Brazilian Real (BRL)", "British Pound (GBP)", "Canadian Dollar (CAD)",
    	  "Chinese Yuan (CNY)", "Danish Krone (DKK)", "Euro (EUR)", "Hong Kong Dollar (HKD)", 
    	  "Indian Rupee (INR)", "Japanese Yen (JPY)", "Malaysian Ringgit (MYR)", "Mexican Peso (MXN)",
    	  "New Zealand Dollar (NZD)", "Norwegian Kroner (NOK)", "Singapore Dollar (SGD)", 
    	  "South African Rand (ZAR)", "South Korean Won (KRW)", "Sri Lanka Rupee (LKR)", 
    	  "Swedish Krona (SEK)", "Swiss Franc (CHF)", "Taiwan Dollar (TVD)", "Thai Baht (THB)",
    	  "Venezuelan Bolivar (YEB)"};
    		/* Descriptions of each of the currency types that can be converted */
       float Curr_Conv_Factor;      /* Individual currency conversion factor read from
                                       file to be used to fill the array */
       float Currency_Conv[24][24]; /* Array containing currency conversion factors */
       int   Row;                   /* Row position in currency conversion array */
       int   Column;                /* Column position in currency conversion array */
    
       /* Definitions of each of the additional subroutines, (functions as they're called
        in C, C++, and C#) for showing each of the currency conversion menu options, do
        any selected conversion, or transfer to a different function.   */
       void  USD_Menu();
    
       int   CLR_Screen(); /* Function to clear the screen and reposition the cursor
                              so that the menus do not scroll off the screen.  */
    
       std::fstream infile;         /* Define/create object type to be used for accessing
                                       the contents of the file. */
    
    main()
     {
      std::fstream infile; /* Define/create object type to be used for accessing
                              the contents of the file. */
      
      infile.open( "currency exchange rates.csv", std::ios::in );
      std::string field;
    
      while( infile.good() )
      {
        /* Check if the file is still good in your inner loops too  */
       for (Row = 0; Row < 24 && infile.good(); Row++)
       {
         for (Column = 0; Column < 24 && infile.good(); Column++)
         {
           if (Column == (24 - 1))
           std::getline(infile, field);/* Last field on a line isn't comma-delimited */
           else
           std::getline(infile, field, ','); /* But the rest are */
    
       Curr_Conv_Factor = std::atof(field.c_str()); /* Convert string to floating point numeric */
            
       Currency_Conv[Row][Column] = Curr_Conv_Factor; /* Load each record read into the
                                                           appropriate array element */
         }
       }
      }
      USD_Menu();
      return 0;
    }
    
    int  CLR_Screen()
      {
        system ("cls");
        return(0);
      }
    
    void USD_Menu()
      {
        CLR_Screen();
        printf("Currency Conversion\n",        month date year);
    	printf("%sConversion Menu\n\n", Currency_Desc[0]);
        printf("\nMenu1");
        printf("\n");
    	printf("A02.  USD to AUD        Y02.  Transfer to AUD Conversion Menu\n");
    	printf("A03.  USD to BRL        Y03.  Transfer to BRL Conversion Menu\n");
    	printf("A04.  USD to GBP        Y04.  Transfer to GBP Conversion Menu\n");
    	printf("A05.  USD to CAD        Y05.  Transfer to CAD Conversion Menu\n");
    	printf("A06.  USD to CNY        Y06.  Transfer to CNY Conversion Menu\n");
    	printf("A07.  USD to DKK        Y07.  Transfer to DKK Conversion Menu\n");
    	printf("A08.  USD to EUR        Y08.  Transfer to EUR Conversion Menu\n");
    	printf("A09.  USD to HKD        Y09.  Transfer to HKD Conversion Menu\n");
    	printf("A10.  USD to INR        Y10.  Transfer to INR Conversion Menu\n");
    	printf("A11.  USD to JPY        Y11.  Transfer to JPY Conversion Menu\n");
    	printf("A12.  USD to MYR        Y12.  Transfer to MYR Conversion Menu\n");
    	printf("A13.  USD to MXN        Y13.  Transfer to MXN Conversion Menu\n");
    	printf("A14.  USD to NZD        Y14.  Transfer to NZD Conversion Menu\n");
    	printf("A15.  USD to NOK        Y15.  Transfer to NOK Conversion Menu\n");
    	printf("A16.  USD to SGD        Y16.  Transfer to SGD Conversion Menu\n");
    	printf("A17.  USD to ZAR        Y17.  Transfer to ZAR Conversion Menu\n");
    	printf("A18.  USD to KRW        Y18.  Transfer to KRW Conversion Menu\n");
    	printf("A19.  USD to LKR        Y19.  Transfer to LKR Conversion Menu\n");
    	printf("A20.  USD to SEK        Y20.  Transfer to SEK Conversion Menu\n");
    	printf("A21.  USD to CHF        Y21.  Transfer to CHF Conversion Menu\n");
    	printf("A22.  USD to TVD        Y22.  Transfer to TVD Conversion Menu\n");
    	printf("A23.  USD to THB        Y23.  Transfer to THB Conversion Menu\n");
    	printf("A24.  USD to YEB        Y24.  Transfer to YEB Conversion Menu\n\n");
    	printf("Q.  Exit Program\n");
        printf("Option: ");
    	scanf("%s", Menu_Opt);
    
        int Opt_Num;
    
        Menu_Opt[0] = toupper(Menu_Opt[0]);
        Opt_Num = atoi(Menu_Opt + 1);
    
        if( Menu_Opt[0] == 'Q')
           {
             return;
           }
        if( Menu_Opt[0] != 'A' && Menu_Opt[0] != 'Y')
           {
            printf("\nInvalid menu option, program is now exiting");
            return;
           }
        if( Opt_Num <= 1 || Opt_Num > 24)
           {
            printf("\nInvalid menu option, program is now exiting");
            return;
           }
    
        if( strcmp(Menu_Opt,"A02") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    		New_Curr_Amt = Org_Curr_Amt * Currency_Conv[0][1];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[1], New_Curr_Amt);
            }
    	if( strcmp(Menu_Opt,"A03") == 0)
    	 	{
    	 	printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    	 	scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[2][0];
    	 	printf("\nYour Equivalent %s is %f\n", Currency_Desc[2], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A04") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[3][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[3], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A05") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[4][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[4], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A06") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[5][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[5], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A07") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[6][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[6], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A08") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[7][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[7], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A09") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[8][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[8], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A10") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[9][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[9], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A11") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[10][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[10], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A12") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[11][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[11], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A13") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[12][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[12], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A14") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[13][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[13], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A15") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[14][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[14], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A16") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[15][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[15], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A17") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[16][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[16], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A18") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[17][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[17], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A19") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[18][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[18], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A20") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[19][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[19], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A21") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[20][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[20], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A22") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[21][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[21], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A23") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[22][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[22], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A24") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[23][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[23], New_Curr_Amt);
    		}
    }
    Now here are the errors I am receiving during the compile:

    Code:
    c:\dev-c_~1\examples\menusa~1.cpp: In function `void USD_Menu()':
    c:\dev-c_~1\examples\menusa~1.cpp:78: `month' undeclared (first use this function)
    c:\dev-c_~1\examples\menusa~1.cpp:78: (Each undeclared identifier is reported only once
    c:\dev-c_~1\examples\menusa~1.cpp:78: for each function it appears in.)
    c:\dev-c_~1\examples\menusa~1.cpp:78: parse error before `year'
    I also want to add the system time to this menu once I can get the date to work properly. So I will be probably asking about that too.
    Last edited by AQWst; 12-23-2004 at 08:23 PM. Reason: Fogot one sentence

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Now here are the errors I am receiving
    c:\dev-c_~1\examples\menusa~1.cpp: In function `void USD_Menu()':
    c:\dev-c_~1\examples\menusa~1.cpp:78: `month' undeclared (first use this function)
    c:\dev-c_~1\examples\menusa~1.cpp:78: (Each undeclared identifier is reported only once
    c:\dev-c_~1\examples\menusa~1.cpp:78: for each function it appears in.)
    c:\dev-c_~1\examples\menusa~1.cpp:78: parse error before `year'
    well of course you are

    >> printf("Currency Conversion\n", month date year); /* line: 78 */
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  6. #6
    Registered User
    Join Date
    Nov 2004
    Posts
    41
    Well, is there any hope for my code, or do you have a different approach that I can take to get this to work?

  7. #7
    Registered User
    Join Date
    Dec 2004
    Posts
    32
    I will give you an example of how to use "asctime" I got it from here
    http://msdn.microsoft.com/library/en...._wasctime.asp

    Code:
    #include <ctime>
    #include <cstdio>
    
    struct tm *newtime;
    time_t aclock;
    
    int main()
    {
    	time( &aclock );   // Get time in seconds
    	newtime = localtime( &aclock );   // Convert time to struct tm form 
    
    	/* Print local time as a string */
    	printf( "Current date and time: %s", asctime( newtime ) );
    
    	/* Print Individual elements of time as a decimal */
    	/* Print Month as a decimal */
    	printf( "Month : %d  \n", (1+(*newtime).tm_mon));
    	/* Print Day as a decimal */
    	printf( "Day : %d \n", (*newtime).tm_mday);
    	/* Print Year as a decimal */
    	printf( "Year : %d \n", (1900+(*newtime).tm_year));
    	return 0;
    }

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    what I meant was:

    >> month date year

    why is that line in the printf() call?

    1) if it's a string literal, put some quotes around it.
    2) if they are variables, declare them and pass them correctly to printf.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #9
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    Header File Questions

    I added the code suggested in the previous post to my exiting code...see below:


    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <cstdio>
    #include <ctime>
    #include <fstream>
    #include <iostream>
    #include <string>
    
    
    
      char  Menu_Opt[4];   		/* Menu Option                 */
       char *ctime( const time_t *time );
       float Org_Curr_Amt = 0.00;	/* Original Currency Amount    */
       float New_Curr_Amt = 0.00;	/* New Currency Amount         */
       char  Currency_Desc[24][100] = {"American Dollar (USD)", "Australian Dollar (AUD)",
    	  "Brazilian Real (BRL)", "British Pound (GBP)", "Canadian Dollar (CAD)",
    	  "Chinese Yuan (CNY)", "Danish Krone (DKK)", "Euro (EUR)", "Hong Kong Dollar (HKD)", 
    	  "Indian Rupee (INR)", "Japanese Yen (JPY)", "Malaysian Ringgit (MYR)", "Mexican Peso (MXN)",
    	  "New Zealand Dollar (NZD)", "Norwegian Kroner (NOK)", "Singapore Dollar (SGD)", 
    	  "South African Rand (ZAR)", "South Korean Won (KRW)", "Sri Lanka Rupee (LKR)", 
    	  "Swedish Krona (SEK)", "Swiss Franc (CHF)", "Taiwan Dollar (TVD)", "Thai Baht (THB)",
    	  "Venezuelan Bolivar (YEB)"};
    		/* Descriptions of each of the currency types that can be converted */
       float Curr_Conv_Factor;      /* Individual currency conversion factor read from
                                       file to be used to fill the array */
       float Currency_Conv[24][24]; /* Array containing currency conversion factors */
       int   Row;                   /* Row position in currency conversion array */
       int   Column;                /* Column position in currency conversion array */
    
       struct tm *newtime
       time_t aclock;         /* Line 32 */
    
    
       /* Definitions of each of the additional subroutines, (functions as they're called
        in C, C++, and C#) for showing each of the currency conversion menu options, do
        any selected conversion, or transfer to a different function.   */
       void  USD_Menu();
    
       int   CLR_Screen(); /* Function to clear the screen and reposition the cursor
                              so that the menus do not scroll off the screen.  */
    
       std::fstream infile;         /* Define/create object type to be used for accessing
                                       the contents of the file. */
    
    main()
     {
      std::fstream infile; /* Define/create object type to be used for accessing
                              the contents of the file. */
      
      infile.open( "currency exchange rates.csv", std::ios::in );
      std::string field;
    
      while( infile.good() )
      {
        /* Check if the file is still good in your inner loops too  */
       for (Row = 0; Row < 24 && infile.good(); Row++)
       {
         for (Column = 0; Column < 24 && infile.good(); Column++)
         {
           if (Column == (24 - 1))
           std::getline(infile, field);/* Last field on a line isn't comma-delimited */
           else
           std::getline(infile, field, ','); /* But the rest are */
    
       Curr_Conv_Factor = std::atof(field.c_str()); /* Convert string to floating point numeric */
            
       Currency_Conv[Row][Column] = Curr_Conv_Factor; /* Load each record read into the
                                                           appropriate array element */
         }
       }
      }
      system("mode con:lines=40");
      system("mode con:cols=100");
    
      time( &aclock );   // Get time in seconds    /*  Line 76  */
    	newtime = localtime( &aclock );   // Convert time to struct tm form 
    
    	/* Print local time as a string */
    	printf( "Current date and time: %s", asctime( newtime ) );
    
    	/* Print Individual elements of time as a decimal */
    	/* Print Month as a decimal */
    	printf( "Month : %d  \n", (1+(*newtime).tm_mon));
    	/* Print Day as a decimal */
    	printf( "Day : %d \n", (*newtime).tm_mday);
    	/* Print Year as a decimal */
    	printf( "Year : %d \n", (1900+(*newtime).tm_year));
    
      USD_Menu();
      return 0;
    }
    
    int  CLR_Screen()
      {
        system ("cls");
        return(0);
      }
    
    void USD_Menu()
      {
        CLR_Screen();
       /* printf("Currency Conversion\n",        month date year); */
    	printf("%sConversion Menu\n\n", Currency_Desc[0]);
        printf("\nMenu1");
        printf("\n");
    	printf("A02.  USD to AUD        Y02.  Transfer to AUD Conversion Menu\n");
    	printf("A03.  USD to BRL        Y03.  Transfer to BRL Conversion Menu\n");
    	printf("A04.  USD to GBP        Y04.  Transfer to GBP Conversion Menu\n");
    	printf("A05.  USD to CAD        Y05.  Transfer to CAD Conversion Menu\n");
    	printf("A06.  USD to CNY        Y06.  Transfer to CNY Conversion Menu\n");
    	printf("A07.  USD to DKK        Y07.  Transfer to DKK Conversion Menu\n");
    	printf("A08.  USD to EUR        Y08.  Transfer to EUR Conversion Menu\n");
    	printf("A09.  USD to HKD        Y09.  Transfer to HKD Conversion Menu\n");
    	printf("A10.  USD to INR        Y10.  Transfer to INR Conversion Menu\n");
    	printf("A11.  USD to JPY        Y11.  Transfer to JPY Conversion Menu\n");
    	printf("A12.  USD to MYR        Y12.  Transfer to MYR Conversion Menu\n");
    	printf("A13.  USD to MXN        Y13.  Transfer to MXN Conversion Menu\n");
    	printf("A14.  USD to NZD        Y14.  Transfer to NZD Conversion Menu\n");
    	printf("A15.  USD to NOK        Y15.  Transfer to NOK Conversion Menu\n");
    	printf("A16.  USD to SGD        Y16.  Transfer to SGD Conversion Menu\n");
    	printf("A17.  USD to ZAR        Y17.  Transfer to ZAR Conversion Menu\n");
    	printf("A18.  USD to KRW        Y18.  Transfer to KRW Conversion Menu\n");
    	printf("A19.  USD to LKR        Y19.  Transfer to LKR Conversion Menu\n");
    	printf("A20.  USD to SEK        Y20.  Transfer to SEK Conversion Menu\n");
    	printf("A21.  USD to CHF        Y21.  Transfer to CHF Conversion Menu\n");
    	printf("A22.  USD to TVD        Y22.  Transfer to TVD Conversion Menu\n");
    	printf("A23.  USD to THB        Y23.  Transfer to THB Conversion Menu\n");
    	printf("A24.  USD to YEB        Y24.  Transfer to YEB Conversion Menu\n\n");
    	printf("Q.  Exit Program\n");
        printf("Option: ");
    	scanf("%s", Menu_Opt);
    
        int Opt_Num;
    
        Menu_Opt[0] = toupper(Menu_Opt[0]);
        Opt_Num = atoi(Menu_Opt + 1);
    
        if( Menu_Opt[0] == 'Q')
           {
             return;
           }
        if( Menu_Opt[0] != 'A' && Menu_Opt[0] != 'Y')
           {
            printf("\nInvalid menu option, program is now exiting");
            return;
           }
        if( Opt_Num <= 1 || Opt_Num > 24)
           {
            printf("\nInvalid menu option, program is now exiting");
            return;
           }
    
        if( strcmp(Menu_Opt,"A02") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    		New_Curr_Amt = Org_Curr_Amt * Currency_Conv[0][1];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[1], New_Curr_Amt);
            }
    	if( strcmp(Menu_Opt,"A03") == 0)
    	 	{
    	 	printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    	 	scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[2][0];
    	 	printf("\nYour Equivalent %s is %f\n", Currency_Desc[2], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A04") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[3][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[3], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A05") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[4][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[4], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A06") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[5][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[5], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A07") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[6][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[6], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A08") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[7][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[7], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A09") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[8][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[8], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A10") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[9][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[9], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A11") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[10][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[10], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A12") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[11][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[11], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A13") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[12][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[12], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A14") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[13][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[13], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A15") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[14][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[14], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A16") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[15][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[15], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A17") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[16][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[16], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A18") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[17][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[17], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A19") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[18][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[18], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A20") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[19][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[19], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A21") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[20][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[20], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A22") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[21][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[21], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A23") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[22][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[22], New_Curr_Amt);
    		}
    	if( strcmp(Menu_Opt, "A24") == 0)
    		{
    		printf("\nPlease enter your value of %s ", Currency_Desc[0]);
    		scanf("%g", &Org_Curr_Amt);
    	 	New_Curr_Amt = Org_Curr_Amt * Currency_Conv[23][0];
    		printf("\nYour Equivalent %s is %f\n", Currency_Desc[23], New_Curr_Amt);
    		}
    }
    I am now getting the following errors:

    Code:
    c:\dev-c_~1\examples\menusa~1.cpp:32: syntax error before `aclock'
    c:\dev-c_~1\examples\menusa~1.cpp: In function `int main()':
    c:\dev-c_~1\examples\menusa~1.cpp:76: `aclock' undeclared (first use this function)
    c:\dev-c_~1\examples\menusa~1.cpp:76: (Each undeclared identifier is reported only once
    c:\dev-c_~1\examples\menusa~1.cpp:76: for each function it appears in.)
    c:\dev-c_~1\examples\menusa~1.cpp:77: `newtime' undeclared (first use this function)

  10. #10
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    well, the line directly above line is 32:

    >> struct tm *newtime

    you need to look at the lines in the compiler output and go to that section in the code and inspect it. if you see a syntax error, fix it. and don't forget to include <ctype>.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  11. #11
    Registered User
    Join Date
    Nov 2004
    Posts
    41
    I guess I was looking at the code too long and missed that line 31 was missing a ";"..thanks for all your help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 04:53 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 01:36 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

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