I'm just going to reiterate somethings that
jeffsg605 wrote earlier and hopefully add a little more detail.
Firstly, please use the
code tags to encase you code, this will help us read your code and help you. A lot of contributors won't read your code if you don't use code tags!
For example:
[ code ]Your Code[ /code ] (
without the spaces) will look like this
Your Code
.
harry14 wrote: |
---|
er...I don't really the get the main void one, suppose in this program I used void main and it returned fine |
Although
void main() { }
may compile successfully without consequence in some compilers, others will spit out warnings and even errors!
I can't quote scripture but
int main() { return 0; }
is not only good practice, but is
required.
You have invoked both the
cin
and
cout
objects but not defined the
scope (
I've included a link below if you want to read more.) of the object.
You don't need a thorough understanding of scope (
yet) but you must define it by invoking the
using
statement, for example:
using namespace std;
harry14 wrote: |
---|
cout << "Science -";/n |
As for your
newlines ("
/n"), you have used the incorrect slash.
Escape characters (
I've included a link below if you want to read more.) are prefixed by the
backslash "\" NOT the
forward slash "/" and also the escape character needs to be
within the double quotes cout<<"Your Text\n"
.
Looking at your code I think you were looking for the
endl
object. You can invoke it like this:
cout<<"Your Text" <<endl;
harry14 wrote: |
---|
I downloaded Microsoft Visual C++ 2010 and I can't find how to create a source file and run it, any ideas? |
To create a "solution" (
something that will hold all of your source files and resources), you need to go to the menu bar and click
File->
New->
Project, you will be greeted by the
New Project wizard, then you need to select what type of project you want to create which in your case is a
Win32 Console Application (
have a look around I'm sure you'll find it). Click
OK then in the next screen click
next then check
Empty Project then click
Finish.
Then you need to add
.cpp files to your Project by right clicking on your Project in the
Solution Explorer (
this is usually on the left) and clicking
Add->
NewItem and selecting .cpp file from the list.
That's about as detailed as I'm willing to do, I hope I've not added to your confusion.
For more info see:
http://msdn.microsoft.com/en-us/library/4457htyc%28v=VS.100%29.aspx
Have a little explore around the I.D.E. you'll get the hang of it eventually.
I hope this helps!
Scope:
http://en.wikipedia.org/wiki/Scope_%28computer_science%29
Escape Characters:
http://en.wikipedia.org/wiki/Escape_character