-
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.
-
post the code, it will be easier to spot a problem
-
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.
-
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 (k–273.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
-
If any my codes are not right,plz tell me what the wrong is ?
Thank you.
-
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.
-
Alternately, you could delete those functions from your source file, and then copy and paste them back into the file from here.
-
.......
-
Some of your - signs are actually – signs (wide dashes) - probably because Word or a similar program auto-converted them. Don't use word processors for programming.
-
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.
-
I use "EditPlus" for Programming and MSYS to COmpile and Run
-
I don't understand CornedBee's and Salem's
-
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.
-
> Some of your - signs are actually – 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)
-
Thank you all , I already understand ,and now I can compile it .
Thanks again.