This is the message I am getting when I try to compile it.
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? -
// Furniture.cpp - This program calculates prices for custom made tables.
-
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
int main()
-
{
-
double Charge = 0.0;
-
double Length = 50;
-
double Width = 40;
-
double Area = 0.0;
-
string wood type = 'oak';
-
string wood type = 'mahogany';
-
string wood type = 'pine';
-
double leaves = 2;
-
-
const int charge = 150.00
-
if area > 750 then charge = 200
-
if wood type = mahogany then charge 350
-
if wood type = oak then charge = 250
-
if leaves = #*50 + charge
-
-
-
-
-
// Output charge for this table
-
cout << "The charge for this table is $" << charge << endl;
-
return(0);
-
}
-
}
-
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(31 ) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>Build log was saved at "file://c:\Users\JimSha\Documents\Visual Studio 2008\Projects\furniture\furniture\Debug\BuildLog.h tm"
1>furniture - 1 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
10 3689
Your variable names are not allowed to have spaces: wood type. Use woodtype or WoodType pr wood_type.
Also, your if statements are not correct. The condition has to be in parentheses.
not
Thank you so much. I am having alot of trouble and I appreciate all your help!
You have created a Windows Console Application rather than a Console Application.
The easiest thing for a beginner is to create a new project as follows:
1) Create a Win32 project.
2) When the wizard appears DO NOT CLICK FINISH.
3) Instead, click Application Settings
4) Select: Console Application and Empty Project
5) Click Finish.
This removes the stdafx.h and pre-compiled header requirements.
BTW: When you run the program be sure to use Start Without Debugging. That will cause VC++ to stop execution at the end of main() so you can see what happened. If you just Start, all you will see is a black flash as your program executed. You select Start when you are using your debugger.
Thanks again. I got past the intial problem with your help. Now I am getting a different message. If you could add some insight to what I am doing wrong I would really appreciate it !
1>------ Build started: Project: Furniture, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>Furniture.cpp
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19 ) : error C2440: 'initializing' : cannot convert from 'int' to 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(20 ) : error C2374: 'wood_type' : redefinition; multiple initialization
1> c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19 ) : see declaration of 'wood_type'
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(20 ) : error C2015: too many characters in constant
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(21 ) : error C2374: 'wood_type' : redefinition; multiple initialization
1> c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19 ) : see declaration of 'wood_type'
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(21 ) : error C2440: 'initializing' : cannot convert from 'int' to 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25 ) : warning C4244: 'initializing' : conversion from 'double' to 'const int', possible loss of data
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25 ) : error C2143: syntax error : missing ';' before 'if'
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25 ) : error C2061: syntax error : identifier 'area'
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(28 ) : error C2014: preprocessor command must start as first nonwhite space
1>Build log was saved at "file://c:\Users\JimSha\Documents\Visual Studio 2008\Projects\Furniture\Furniture\Debug\BuildLog.h tm"
1>Furniture - 8 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19 ) : error C2440: 'initializing' : cannot convert from 'int' to
The compiler got in trouble on lin 19 of furniture.cpp.
What is that line? The error is there or it is earlier than line 19.
The other errors are irrelevant. Often these are caused as a result iof the first error.
What you do is fix the first error and rebuild. Then fix the first error and rebuild. Etc... At some point all the subsequent errors just vanish.
Here is what I got now, I changed the wood type to WoodType and I still get an error. -
// Furniture.cpp : Defines the entry point for the console application.
-
//
-
-
#include "stdafx.h"
-
-
-
// Furniture.cpp - This program calculates prices for custom made tables.
-
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
int main()
-
-
{
-
double Charge = 0.0;
-
double Length = 50;
-
double Width = 40;
-
double Area = 0.0;
-
string WoodType = 'oak';
-
string WoodType = 'mahogany';
-
string WoodType = 'pine';
-
double leaves = 2;
-
-
const int charge = 150.00
-
if area > 750 then charge = 200
-
if WoodTyp = mahogany then charge 350
-
if WoodType = oak then charge = 250
-
if leaves = #*50 + charge
-
-
-
-
-
// Output charge for this table
-
cout << "The charge for this table is $" << charge << endl;
-
return(0);
-
}
-
This is what I get for errors. -
1>------ Build started: Project: Furniture, Configuration: Debug Win32 ------
-
1>Compiling...
-
1>Furniture.cpp
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19) : error C2440: 'initializing' : cannot convert from 'int' to 'std::basic_string<_Elem,_Traits,_Ax>'
-
1> with
-
1> [
-
1> _Elem=char,
-
1> _Traits=std::char_traits<char>,
-
1> _Ax=std::allocator<char>
-
1> ]
-
1> No constructor could take the source type, or constructor overload resolution was ambiguous
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(20) : error C2374: 'WoodType' : redefinition; multiple initialization
-
1> c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19) : see declaration of 'WoodType'
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(20) : error C2015: too many characters in constant
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(21) : error C2374: 'WoodType' : redefinition; multiple initialization
-
1> c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19) : see declaration of 'WoodType'
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(21) : error C2440: 'initializing' : cannot convert from 'int' to 'std::basic_string<_Elem,_Traits,_Ax>'
-
1> with
-
1> [
-
1> _Elem=char,
-
1> _Traits=std::char_traits<char>,
-
1> _Ax=std::allocator<char>
-
1> ]
-
1> No constructor could take the source type, or constructor overload resolution was ambiguous
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25) : warning C4244: 'initializing' : conversion from 'double' to 'const int', possible loss of data
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25) : error C2143: syntax error : missing ';' before 'if'
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25) : error C2061: syntax error : identifier 'area'
-
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(28) : error C2014: preprocessor command must start as first nonwhite space
-
1>Build log was saved at "file://c:\Users\JimSha\Documents\Visual Studio 2008\Projects\Furniture\Furniture\Debug\BuildLog.htm"
-
1>Furniture - 8 error(s), 1 warning(s)
-
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-
-
Thanks agaian, I know this must seem elementry to you but I am really confused
Look at this code:
A literal string needs double quotes rather than single quotes. Single quotes are for single characters.
Try:
Also, there is one place wheere you have WoodTyp rather than WoodType.
Gotta be careful. The compiler is really fussy.
I got past the string problem. Thanks I don't how it would have took me without your help!!! Now my problem has moved down to line 25, 26, 28. Do you see what I did wrong? -
// Furniture.cpp - This program calculates prices for custom made tables.
-
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
int main()
-
-
{
-
double Charge = 0.0;
-
double Length = 50;
-
double Width = 40;
-
double Area = 0.0;
-
string WoodType1 = "'oak'";
-
string WoodType2 = "'mahogany'";
-
string WoodType3 = "'pine'";
-
double leaves = 2;
-
-
const double charge = 150.00
-
if area > 750 than charge = 200
-
if WoodType2 = mahogany then charge 350
-
if WoodType1 = oak then charge = 250
-
if leaves = #*50 + charge
-
-
-
-
-
// Output charge for this table
-
cout << "The charge for this table is $" << charge << endl;
-
return(0);
-
}
-
Here are the errors now.
1>Compiling...
1>Furniture.cpp
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25 ) : error C2143: syntax error : missing ';' before 'if'
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25 ) : error C2061: syntax error : identifier 'area'
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(28 ) : error C2014: preprocessor command must start as first nonwhite space
1>Build log was saved at "file://c:\Users\JimSha\Documents\Visual Studio 2008\Projects\Furniture\Furniture\Debug\BuildLog.h tm"
1>Furniture - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I only have one error now and I don't know what is causing it. Do you have any ideas? -
// Furniture.cpp : Defines the entry point for the console application.
-
//
-
-
#include "stdafx.h"
-
-
-
// Furniture.cpp - This program calculates prices for custom made tables.
-
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
int main()
-
-
{
-
double Charge = 0.0;
-
double Length = 50;
-
double Width = 40;
-
double area = 0.0;
-
string WoodType1 = "'oak'";
-
string WoodType2 = "'mahogany'";
-
string WoodType3 = "'pine'";
-
double leaves = 2;
-
-
const double charge = 150.00;
-
if area > 750 then charge = 200
-
if "WoodType2" = then charge 350
-
if "WoodType1" = then charge = 250
-
if leaves = number * 50 + charge
-
-
-
-
-
// Output charge for this table
-
cout << "The charge for this table is $" << charge << endl;
-
return(0);
-
1>------ Build started: Project: Furniture, Configuration: Debug Win32 ------
1>Compiling...
1>Furniture.cpp
1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25 ) : error C2061: syntax error : identifier 'area'
1>Build log was saved at "file://c:\Users\JimSha\Documents\Visual Studio 2008\Projects\Furniture\Furniture\Debug\BuildLog.h tm"
1>Furniture - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please read about syntax before you try to use it.
I said in an earlier post that an if statement has the condition inside parentheses:
and not
Carefully look at your code.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Heinz |
last post by:
Hello,
I have a project that is used by other project in my solution. This common
project is also used by a VB6 application (so it is placed in GAC).
Since I did this (this is what I...
|
by: Enos Meroka |
last post by:
Hallo,
I am a student doing my project in the university.. I have been trying
to compile the program using HP -UX aCC compiler, however I keep on
getting the following errors.
...
|
by: SHC |
last post by:
Hi all,
I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console
application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and
books.xsd (see the attached files below)...
|
by: Bill Sun |
last post by:
Hi,
I just want to using a console application in the .net enviroment.
Before the main(), I using the
#include "iostream.h"
but the .net tell me:...
|
by: hb |
last post by:
Hi,
I have been working on the ASP.Net project for months with VS.Net 2003 in C#.
But this afternoon I suddenly got the following error when I tied to compile the
whole solution:
===
------...
| |
by: David zhu |
last post by:
fatal error CS0042: Unexpected error creating debug
information file
C:\Inetpub\wwwroot\HSBCS\Pages\HsWebBase\obj\Debug\HsWebBas
e.PDB'--...
|
by: Ron St-Pierre |
last post by:
We're developing a java app and are using postgres as the database. On
our dev server I started the app, closed it, but the java process was
still open so I killed it, which caused the above error....
|
by: eshuv |
last post by:
hi
I am faceing this problem when comlling the .cpp file .
fatal error C1004: unexpected end of file found
|
by: kvarada |
last post by:
Hello Experts,
I am building my application on WinNT.4.0_i386_MSVC.7.1 platform. When I build the application on a stand alone machine, it builds fine. But when I build the same application from a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |