Please Help!!!

This is a discussion on Please Help!!! within the C++ Programming forums, part of the General Programming Boards category; I gota problem. Plese help me to solve. temperature.cpp: In function `double FtoC(double)': temperature.cpp:11: stray '6' in program temperature.cpp:11: parse ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    11

    Please Help!!!

    I gota problem.

    Plese help me to solve.

    temperature.cpp: In function `double FtoC(double)':
    temperature.cpp:11: stray '\226' in program
    temperature.cpp:11: parse error before numeric constant
    temperature.cpp: In function `double KtoC(double)':
    temperature.cpp:15: stray '\226' in program
    temperature.cpp:15: parse error before numeric constant


    Thanks.

  2. #2
    *this
    Join Date
    Mar 2005
    Posts
    498
    post the code, it will be easier to spot a problem

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,243
    At a guess, you've managed to get some strange characters into your temperature.cpp file. If you've used an editor like Microsoft word to edit your file, you need to save your file as a text file. Usually, you will be better off using a straight text editor or a program designed specifically for editing source code.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    11

    F1uT3_Code

    Code:
      
    temperature.h
    
    #ifndef TEMPERATURE_H
    #define TEMPERATURE_H
    
    double FtoC(double);  // c = (5/9) * (f 32)
    //Function FtoC() return temperature by converting Fahrenhiet to Celsius
    	
    double KtoC(double);  // c = k  273.2
    //Function KtoC() return temperature by converting Kelvin to Celsius
    /*
    double CtoK(double);  // k = c + 273.2
    //Function CtoK() return temperature by converting Celsius to Kelvin
    
    double CtoF(double);  // f = (9/5) * c + 32
    //Function CtoF() return temperature by converting Celsius to Fahrenhiet
    */
    void tableheading();
    //Create Table Heading
    
    #endif
    
    DONE BY F1uT3
    Code:
    temperature.cpp
    
    #include"temperature.h"
    #include <iostream>
    #include <iomanip>
    using std::cout;
    using std::setw;
    //Function Definitions
    //Functions of temperatures by using Celsius as a base for converting to Fahrenheit and Kelvin.
    /*
    double FtoC(double f)  // Function for converting Fahrenheit to Celsius
    {
    	return (f-32)*5.0/9;
    }
    double KtoC(double k)  // Function for converting Kelvin to Celsius
    {
    	return  (k273.2);
    }*/
    double CtoK(double c)  // Function for converting Celsius to Kelvin
    {
    	return  c+273.2;
    }
    double CtoF(double c)  // Function for converting Celsius to Fahrenheit 
    {
    	return 9.0/5*c+32;
    }
    void tableheading()
    {
    	//Print a table heading
    	cout<<"******************************";
    	cout<<setw(8)<<"\nCelsius|"
    		<<setw(12)<<"Fahrenheit|"
    		<<setw(8)<<" Kelvin |"
    		<<setw(8)<<"Celsius|"
    		<<setw(8)<<"Celsius|"
    		<<setw(8)<<"Celsius|";
    	cout<<setw(8)<<"\nC_Base|"
    		<<setw(12)<<"C_Base2F |"
    		<<setw(8)<<"C_Base2K|"
    		<<setw(12)<<"K_Base2C|"
    		<<setw(12)<<"F_Base2C|"
    		<<setw(8)<<"C_Base|";
    	cout<<"\n******************************\n";
    }
    
    DONE BY F1uT3
    Code:
    temptable.cpp
    
    /*Write a program to display a nice table of temperatures showing temperature values of Celsius, 
    Kelvin and Fahrenheit for Celsius values of ranging from 50 to + 150 utilizing the library.*/
    #include"temperature.h"
    #include <iostream>
    #include <iomanip>
    using std::cout;
    using std::cin;
    using std::endl;
    using std::setw;
    using std::setprecision;
    using std::fixed;
    
    int main()
    {
    	//========Declare Variables========
    	double c,f,k,c2f,c2k,f2c,k2c;
    	double lowest_c=-50;
    	double highest_c=150;
    	double step_size=1;
    
    	//========Display A Welcome Statement========
    	cout<<"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"<<endl;
    	cout<<"-------- This is a program , a conversion table of temperatures(C,F,K). --------"<<endl;
    	cout<<"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"<<endl;
    
    	//========Display A Table of Temperatures========
    
    	tableheading();
    
    	for(c=lowest_c ; c<=highest_c ; c+=step_size)
    	{
    		cout<<setw(5)<<setprecision(0)<<c;
    		c2f=CtoF(c);
    		cout<<setw(12)<<fixed<<setprecision(2)<<c2f;
    		c2k=CtoK(c);
    		cout<<setw(10)<<fixed<<setprecision(2)<<c2k;
    	/*for(k=223.20 ; k<=423.20 ; k+=step_size)
    	{
    		k2c=KtoC(k);
    		cout<<setw(10)<<fixed<<setprecision(2)<<k2c;
    	}
    	for(f=102.00 ; f<=302.00 ; f+=step_size)
    	{
    		f2c=FtoC(f);
    		cout<<setw(12)<<fixed<<setprecision(2)<<f2c;
    	}
    		cout<<setw(5)<<setprecision(0)<<c;*/
    
    		if(c==-10 || c==30 || c==70 || c==110) //Fix the number shown every pages
    		{
    			cout<<"\nPress Enter to continue ...";
    			cin.get();  //get Enter key to continue
    			tableheading();
    		}
    	}
    
    	return 0;
    }
    
    DONE BY F1uT3
    Last edited by F1uT3; 06-24-2005 at 12:56 PM.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    11
    If any my codes are not right,plz tell me what the wrong is ?

    Thank you.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Can you upload temperature.cpp instead of copying it? The issue is that there's an invalid character somewhere in there, but the copy & paste operation seems to have made it disappear.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Alternately, you could delete those functions from your source file, and then copy and paste them back into the file from here.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    11

    .......

    ..........
    Last edited by F1uT3; 06-24-2005 at 12:42 PM.

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Some of your - signs are actually &ndash; signs (wide dashes) - probably because Word or a similar program auto-converted them. Don't use word processors for programming.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    What he said
    Code:
    72 65 74 75 72 6e 20 20 28 6b 96 32 37 33 2e 32  >return  (k.273.2<
    That - sign isn't really a minus.
    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.

  11. #11
    Registered User
    Join Date
    Jun 2005
    Posts
    11
    I use "EditPlus" for Programming and MSYS to COmpile and Run

  12. #12
    Registered User
    Join Date
    Jun 2005
    Posts
    11
    I don't understand CornedBee's and Salem's

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    They are saying the - character in your code is not a normal dash it is a different character that your compiler doesn't recognize. Wherever you copied your code from, or wherever you typed it in is using the wrong character for the minus sign. Use a different editor.

    One solution is to re-type all your minus signs in an editor that will actually only put regular dashes.

  14. #14
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    > Some of your - signs are actually &ndash; signs (wide dashes) -
    You often get this problem when you copy/paste code which has been mangled to make it HTML-friendly.

    > @ F1uT3
    Just retype the minus signs on lines 11 and 13 (like the error messages say)
    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.

  15. #15
    Registered User
    Join Date
    Jun 2005
    Posts
    11
    Thank you all , I already understand ,and now I can compile it .

    Thanks again.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

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