Compilong C++ in VC++ 2008 express issues

Hi im new to programming, teaching myself, im currently using the V C++ 2008 express edition to learn on, and have found that im getting errors, ive searched the net for my error and still cant get my basic program going, believe im not declaring my variables correctly in the new 2008

My Code

#include <stdafx.h>
#include <iostream>
using namespace std;

int main()
{
double ctemp, ftemp;

cout << "Input celsius temp and press enter: ";
cin >> ctemp;
ftemp = (ctemp * 1.8) + 32;
cout <<"Fahrenheit temp is: " << ftemp;

return 0;

{

My Error:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

very specific, tried typedef and other examples on the net but still cant get it going, any help would be great

thanks
Okay,am new either.But let look on this line.
ftemp=(ctemp*1.8)+32;
try to avoid this line and not declare ftemp double,just use cast:
cout<<"ferenheit temp"<<(double)(ctemp*1.8)+32;
.Am typing from mobile that's why my code look like normal text but if u are typing from pc,u should select your code and press this button."<>".
What is the advantage of the cast? He simply loses more precision.
Except for the fact that you're ending main with an opening brace ({), that program compiles fine for me.
yeah it compiles with me too.. haha {
// Print1.cpp : main project file.

#include <stdafx.h>
#include <iostream>
using namespace std;

int main()
{
double ctemp, ftemp;

cout << "Input celsius temp and press enter: ";
cin >> ctemp;
ftemp = (ctemp * 1.8) + 32;
cout <<"Fahrenheit temp is: " << ftemp;

return 0;

}

closed the brace and still get :

1>.\print4.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

are you guys using visual c++ 2008 express edition?
Last edited on
yes. i have VC++ express. seems to like the error is on another cpp file on the project.. try making another console project and copy paste this code..
Odd, when I copy paste the code into my compiler it compiles just fine, and yes I am using Visual Studio 2008. I'm not using express edition; I do not see how that would effect the compiling of your program, as we're using the same tool essentially. Are you still having problems with this?

-Xitan
I think he has more than one file in his project because if this file is called Print1.cpp why is the error saying there is a problem with Print4.cpp.


(it is just possible I suppose that his file is called print4cpp and not print1.cpp)
Last edited on
thanks, ill take a lok into it, thanks for alkl your help
Still having problems with the same error I was just wondering if any of u can tell me the correct process to open a consol project in vc 2008 enterprise. I normalt just go file new project win32 cobsol application. Is this the correct way to do it
It's better to make a empty project right click on source folder and click add new item, then click the .cpp file give it a name, try some of the above suggestions eg. creating a new empty project and copy pasting the code... Also do you have other cpp files? you talk about print1 and print4. you should really specify what you have done and what doesn't work.

Could you also use code tags in future, there the button on the right that looks like <>

The code definitely works I just tried it in Visual C++ 2010

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;

int main()
{
double ctemp, ftemp;
char a;
cout << "Input celsius temp and press enter: ";
cin >> ctemp;
ftemp = (ctemp * 1.8) + 32;
cout <<"Fahrenheit temp is: " << ftemp;

cin >> a;
return 0;

}
Last edited on
Topic archived. No new replies allowed.