RE: Question: Compiling straight c++ in Visual studio 2010 express c++

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 27 Jun 2010 19:02:43 -0700

Hi,
Oh, welcome then...
I see where you are going... The routine sounds like a basic C++ program to
me. As Qubit's code notes, VS adds some odd info in the main declaration.
You can create a general C++ project with template being a general C++ -
this will prevent VS from adding extra items.
So, let's get to your code...
In the declaration:
int main();
You might want to take out the semicolon. What we are dealing with is a
special thing called functions - a black box type of code that does whatever
to get the job done. In this case, main() is the main program (actually, a
main function). If you are writing a function (which I hope someone from the
list would help you with in the end), you generally don't put semicolon in
the end unless if you are trying to create your own data type and need some
kind of a signature (classes... I think people who has better experience
could teach you that in the long run)...
Now, to the printing part... Yep, you almost got it right; only thing
missing was the two less-than signs (<<) between the right quote and the new
line string (endl). So the typical routine would look like:
// Joseph's advice:
Cout << "Hello World!" << endl;
Cout << "I hope you understand what the code looks like now..." << endl;
One last thing: The braces tells the computer where some data or a function
belongs - the more braces you are in, you are going into two or three levels
deep, like a tree view. So, for instance, if you put two left braces, you
need to put two right braces - to balance things out, otherwise the compiler
will say that whatever came next is not valid... Don't worry, I (and perhaps
others ) have run into this problem without us realizing it 9until we
compiled it)...
So, here is the corrected program (using non-VS additives):
// Joseph's suggested code (at least basic C++):
#include <iostream> // This means that we want to use facilities for input
and output.
#include <string> // This is optional; this just tells the compiler that we
want to manipulate strings.
using namespace std;
int main()
{
// A simple print program to display some text...
cout << "Hello, world!" << endl;
cout << "This is just a simple program..." << endl;
return (0);}
Hope this helps. Feel free to ask any questions, and hopefully the listers
will answer them...
Cheers,
Joseph P.S. I'm using VS2008 with JAWS scripts. 

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Midence
Sent: Sunday, June 27, 2010 12:22 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Question: Compiling straight c++ in Visual studio 2010 express c++

Hi, folks,

I have a question to pose to you all.  First, though, a long-neglected 
introduction.  My name is Alex Midence and I am a trainer by 
profession.  I have recently taken up learning how to code as something 
of a hobby in response to a rather unpleasant run-in with a slew of 
inaccessible applications.  I will trace the somewhat convoluted path 
for you all some day.  For now, though, suffice it to say that I have 
chosen c++ as the language I wish to learn first.  I've found all sorts 
of nifty tutorials on line to get me started.  HOwever, they all seem to 
have one thing in common which leads to my question.

All of the tutorials I've come across including the one in msdn.com 
teach you standard c++.  I've downloaded two compilers and can't get the 
simple programs I'm learning to write to compile in either one of them 
even though I've checked and rechecked my syntax.  The compilers are 
visual studioo c++ express 2010 and Eclipse.  Visual Studio 2010 keeps 
giving me a "code out of date" message and, Eclipse just doesn't run the 
app because maybe I have a mssing component or something.  I can't 
figure that one out and I've sort of given up on it for now so I can 
concentrate on Visual c++ since it seems to be the compiler of choice 
for many develpers out there.  Here is my code.  Could someone please 
tell me what's wrong with it?  Incidentally, Seamonkey, the e-mail 
client I use keeps weeding out the braces, so, I wrote them out so 
someone using speech would hear where they were.  Of course, in the 
editor, I use the real braces.  It's a simple, hello, world-type program:

// Alex's first program.

#include <iostream>

Using Namespace std;
Int main();
{Left brace
cout << "Hello, World." endl;
cout << "This is a c++ program written by alex.";
return 0;
Right brace

Any help you can provide is welcome and greatly appreciated.}

Regards,
Alex

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.439 / Virus Database: 271.1.1/2967 - Release Date: 06/27/10
18:35:00

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: