473,513 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fatal error C1010: unexpected end of file

shashahayes
13 New Member
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?

Expand|Select|Wrap|Line Numbers
  1. // Furniture.cpp - This program calculates prices for custom made tables.
  2.  
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6. int main()
  7. {
  8.      double Charge = 0.0;
  9.         double Length = 50;
  10.      double Width = 40;
  11.         double Area = 0.0;
  12.      string wood type = 'oak';    
  13.      string wood type = 'mahogany';
  14.      string wood type = 'pine';
  15.         double leaves = 2;      
  16.  
  17.       const int charge = 150.00
  18.       if area  > 750 then charge = 200
  19.       if wood type = mahogany then charge 350
  20.       if wood type = oak then charge = 250
  21.       if leaves = #*50 + charge
  22.  
  23.  
  24.  
  25.  
  26.    // Output charge for this table
  27.    cout << "The charge for this table is $" << charge << endl;
  28.    return(0); 
  29. }
  30. }
  31.  

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 ==========
Mar 6 '10 #1
10 3689
weaknessforcats
9,208 Recognized Expert Moderator Expert
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.

Expand|Select|Wrap|Line Numbers
  1. if (A == 3) etc.....
not

Expand|Select|Wrap|Line Numbers
  1. if A == 3
Mar 6 '10 #2
shashahayes
13 New Member
Thank you so much. I am having alot of trouble and I appreciate all your help!
Mar 6 '10 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
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.
Mar 6 '10 #4
shashahayes
13 New Member
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 ==========
Mar 6 '10 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
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.
Mar 6 '10 #6
shashahayes
13 New Member
Here is what I got now, I changed the wood type to WoodType and I still get an error.

Expand|Select|Wrap|Line Numbers
  1. // Furniture.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. // Furniture.cpp - This program calculates prices for custom made tables.
  8.  
  9. #include <iostream>
  10. #include <string>
  11. using namespace std;
  12. int main()
  13.  
  14. {
  15.      double Charge = 0.0;
  16.         double Length = 50;
  17.      double Width = 40;
  18.         double Area = 0.0;
  19.      string WoodType = 'oak';    
  20.      string WoodType = 'mahogany';
  21.      string WoodType = 'pine';
  22.         double leaves = 2;      
  23.  
  24.       const int charge = 150.00
  25.       if area  > 750 then charge = 200
  26.       if WoodTyp = mahogany then charge 350
  27.       if WoodType = oak then charge = 250
  28.       if leaves = #*50 + charge
  29.  
  30.  
  31.  
  32.  
  33.    // Output charge for this table
  34.    cout << "The charge for this table is $" << charge << endl;
  35.    return(0); 
  36. }
  37.  
This is what I get for errors.
Expand|Select|Wrap|Line Numbers
  1. 1>------ Build started: Project: Furniture, Configuration: Debug Win32 ------
  2. 1>Compiling...
  3. 1>Furniture.cpp
  4. 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>'
  5. 1>        with
  6. 1>        [
  7. 1>            _Elem=char,
  8. 1>            _Traits=std::char_traits<char>,
  9. 1>            _Ax=std::allocator<char>
  10. 1>        ]
  11. 1>        No constructor could take the source type, or constructor overload resolution was ambiguous
  12. 1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(20) : error C2374: 'WoodType' : redefinition; multiple initialization
  13. 1>        c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19) : see declaration of 'WoodType'
  14. 1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(20) : error C2015: too many characters in constant
  15. 1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(21) : error C2374: 'WoodType' : redefinition; multiple initialization
  16. 1>        c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(19) : see declaration of 'WoodType'
  17. 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>'
  18. 1>        with
  19. 1>        [
  20. 1>            _Elem=char,
  21. 1>            _Traits=std::char_traits<char>,
  22. 1>            _Ax=std::allocator<char>
  23. 1>        ]
  24. 1>        No constructor could take the source type, or constructor overload resolution was ambiguous
  25. 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
  26. 1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25) : error C2143: syntax error : missing ';' before 'if'
  27. 1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(25) : error C2061: syntax error : identifier 'area'
  28. 1>c:\users\jimsha\documents\visual studio 2008\projects\furniture\furniture\furniture.cpp(28) : error C2014: preprocessor command must start as first nonwhite space
  29. 1>Build log was saved at "file://c:\Users\JimSha\Documents\Visual Studio 2008\Projects\Furniture\Furniture\Debug\BuildLog.htm"
  30. 1>Furniture - 8 error(s), 1 warning(s)
  31. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  32.  
  33.  
Thanks agaian, I know this must seem elementry to you but I am really confused
Mar 6 '10 #7
weaknessforcats
9,208 Recognized Expert Moderator Expert
Look at this code:

Expand|Select|Wrap|Line Numbers
  1. string WoodType = 'oak'; 

A literal string needs double quotes rather than single quotes. Single quotes are for single characters.

Try:

Expand|Select|Wrap|Line Numbers
  1. string WoodType = "oak"; 
Also, there is one place wheere you have WoodTyp rather than WoodType.

Gotta be careful. The compiler is really fussy.
Mar 6 '10 #8
shashahayes
13 New Member
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?

Expand|Select|Wrap|Line Numbers
  1. // Furniture.cpp - This program calculates prices for custom made tables.
  2.  
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6. int main()
  7.  
  8. {
  9.      double Charge = 0.0;
  10.         double Length = 50;
  11.      double Width = 40;
  12.         double Area = 0.0;
  13.      string WoodType1 = "'oak'";    
  14.      string WoodType2 = "'mahogany'";
  15.      string WoodType3 = "'pine'";
  16.         double leaves = 2;      
  17.  
  18.       const double charge = 150.00
  19.       if area  > 750 than charge = 200
  20.       if WoodType2 = mahogany then charge 350
  21.       if WoodType1 = oak then charge = 250
  22.       if leaves = #*50 + charge
  23.  
  24.  
  25.  
  26.  
  27.    // Output charge for this table
  28.    cout << "The charge for this table is $" << charge << endl;
  29.    return(0); 
  30. }
  31.  
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 ==========
Mar 6 '10 #9
shashahayes
13 New Member
I only have one error now and I don't know what is causing it. Do you have any ideas?

Expand|Select|Wrap|Line Numbers
  1. // Furniture.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. // Furniture.cpp - This program calculates prices for custom made tables.
  8.  
  9. #include <iostream>
  10. #include <string>
  11. using namespace std;
  12. int main()
  13.  
  14. {
  15.      double Charge = 0.0;
  16.         double Length = 50;
  17.      double Width = 40;
  18.         double area = 0.0;
  19.      string WoodType1 = "'oak'";    
  20.      string WoodType2 = "'mahogany'";
  21.      string WoodType3 = "'pine'";
  22.         double leaves = 2;      
  23.  
  24.       const double charge = 150.00;
  25.       if area > 750 then charge = 200
  26.       if "WoodType2" = then charge 350
  27.       if "WoodType1" = then charge = 250
  28.       if leaves = number * 50 + charge
  29.  
  30.  
  31.  
  32.  
  33.    // Output charge for this table
  34.    cout << "The charge for this table is $" << charge << endl;
  35.    return(0); 
  36.  
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 ==========
Mar 6 '10 #10
weaknessforcats
9,208 Recognized Expert Moderator Expert
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:

Expand|Select|Wrap|Line Numbers
  1. if (Test == true)
  2. {
  3.  
  4. }
and not

Expand|Select|Wrap|Line Numbers
  1. if Test == true
  2. {
  3.  
  4. }
Carefully look at your code.
Mar 7 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6047
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...
5
5688
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. ...
0
4562
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)...
1
4508
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:...
4
3173
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: === ------...
1
3157
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'--...
2
15230
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....
1
6261
by: eshuv | last post by:
hi I am faceing this problem when comlling the .cpp file . fatal error C1004: unexpected end of file found
1
3743
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...
0
7260
marktang
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,...
0
7537
jinu1996
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...
1
7099
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...
0
5685
agi2029
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,...
1
5086
isladogs
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...
0
4746
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...
0
1594
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 ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.