Debugging question

This is a discussion on Debugging question within the C Programming forums, part of the General Programming Boards category; I am a new member here and a student in C programming. I had to create a program that, at ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    2

    Debugging question

    I am a new member here and a student in C programming. I had to create a program that, at this point< displays currency conversions. I wanted to add an option in the display, using IF, that would make the output grammatically correct.

    For our class, we use Miracle C compiler. When I ran into errors in Miracle C, I tried the code in Visual Studio C++ 2005. In VS it runs fine, but is Miracle C I get the following error;


    Miracle C Compiler (r3.2), written by bts.
    Compiling c:\documents and settings\steve\my documents\week3_sh\week3_sh.c
    main

    c:\documents and settings\steve\my documents\week3_sh\week3_sh.c: line 35: unrecognised types in comparison
    'if (pesos<1) { printf("Each Mexican Peso is worth %.2f cents in US Dollars.\n\n",pesos)'
    aborting compile


    Why would this code work in one program and not there other and what am I missing?

    Here is the code I have written;

    Code:
    /*This program is the basis for a currency converter
      It's function at this point is to display the title and conversions only.*/
    
    /*
    Steve Hohman
    POS 370 Programming Concepts
    May 30,2005
    */  
    
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void)
    
    {
    //Define variables
    	double pesos;
    	double euros;
    	double yen;
    	double cana;
    	double uk;
    	//Define the foreign currency values as floating point numbers
    	
    //Convert foriegn currency to 1 US Dollar
    	pesos=1/.0920090;  //Convert the Mexican Peso to US Dollars
    	euros=1/1.24675;  //Convert the Euro to US Dollars
    	yen=1/.00926255;  //Convert the Japanese Yen to US Dollars
    	cana=1/.796395;  //Convert the Canadian Dollar to US Dollars
    	uk=1/1.82250;  //Convert the United Kingdom Pound to US Dollars
    	
    /*Display the listing of values to the screen.  The purpose of the IF statement
      is for proper display should the currency conversion changes above or below one US Dollar*/
      
    	//Mexican Pesos
    	if (pesos<1)
    	{
    		printf("Each Mexican Peso is worth %.2f cents in US Dollars.\n\n",pesos);
    	}
    	if (pesos>1)
    	{
    		printf("Each Mexican Peso is worth $%.2f in US Dollars.\n\n",pesos);
    	}
    	
    	//Euros
    	if (euros<1)
    	{
    		printf("Each Euro is worth %.2f cents in US Dollars.\n\n",euros);
    	}
    	if (euros>1)
    	{
    		printf("Each Euro is worth $%.2f in US Dollars.\n\n",euros);
    	}
    		
    	//Japanese Yen
    	if (yen<1)
    	{
    		printf("Each Japanese Yen is worth %.2f cents in US Dollars.\n\n",yen);
    	}
    	if (yen>1)
    	{
    		printf("Each Japanese Yen is worth $%.2f in US Dollars.\n\n",yen);
    	}
    	
    	//Canadian Dollars
    	if (cana<1)
    	{
    		printf("Each Canadian Dollar is worth %.2f cents in US Dollars.\n\n",cana);
    	}
    	if (cana>1)
    	{
    		printf("Each Canadian Dollar is worth $%.2f in US Dollars.\n\n",cana);
    	}
    	
    	//British Pounds
    	if (uk<1)
    	{
    		printf("Each British Pound is worth %.2f cents in US Dollars.\n\n",uk);
    	}
    	if (uk>1)
    	{
    		printf("Each British Pound is worth $%.2f in US Dollars.\n\n",uk);
    	}
    	puts("Press the <ENTER> key to end this program...");
    	getchar();  //Wait for <ENTER> key
    	return 0;
    }
    Thanks for any help you can offer.

    Salty

  2. #2
    FOX
    Join Date
    May 2005
    Posts
    188
    Your code is valid C99, and if you remove the "//" comments it'll be ANSI compliant as well.

    You could solve it by using:
    Code:
    if (pesos<1.0)
    But, you shouldn't have to come up with hacks in your own code to correct compiler bugs. If I were you, I would ask your professor why he insists that you use such an exotic and non-standard compiler. It's more of a toy than anything.
    Last edited by ^xor; 05-30-2005 at 02:12 PM.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    2
    Quote Originally Posted by ^xor
    Because you're using a POS compiler... Your code is valid C99, and if you remove the "//" comments it'll be ANSI compliant as well.

    You could solve it by using:
    Code:
    if (pesos<1.0)
    But, you shouldn't have to correct compilers bugs in your own code.
    Thanks you for your help. I adjusted all vales of "1" to "1.0" and it works fine.

    It is hard to learn a programming language with a trashy compiler.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    > For our class, we use Miracle C compiler.
    OMG - NOOOOO
    Your professor is a moron!

    Just do a board search for "miracle c" and find out why.

    Pretty much every other compiler out there does a far better job, and a good number of them are free (MC is nagware - <puke>). Just keep showing your prof how all your prog.c files compile fine with any other compiler, and fail miserably with MC

    Dev-C++ is free, and wipes the floor with MC.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 09:48 AM
  2. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  5. Debugging Question
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 12-19-2001, 04:42 PM

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