So I'm having some difficulties with Visual C++ 2010, or so it would seem. I take examples from either the web or the school text for learning this language and consistently I find myself spending more time troubleshooting the errors that pop up than learning anything.....that's a poor way of wording it...Let me give you an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
1 // Program to add two integers typed by user at keyboard
2 #include <iostream>
3 using namespace std;
4
5 int main()
6 {
7 int a, b, total;
8
9 cout << "Enter integers to be added:" << endl;
10 cin >> a >> b;
11 total = a + b;
12 cout << "The sum is " << total << endl;
13
14 return 0;
15 }
|
returns this kind of error:
1>------ Build started: Project: Add, Configuration: Debug Win32 ------
1> Adding.cpp
1>c:\users\ben\documents\visual studio 2010\projects\add\add\adding.cpp(2): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\ben\documents\visual studio 2010\projects\add\add\adding.cpp(16): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've also received errors stating that CIN and/or COUT are undefined. I simply don't get it. I am following the code exactly and yet these errors persist. Help please!!