PDA

View Full Version : hello world


Quiddity
17-10-2003, 05:50 AM
how would i make a hello world application in vs .net?

Infernal-Shade
17-10-2003, 07:34 AM
#include <iostream>

using std::cout;
using std::endl;

int main()
{
cout << "Hello, world!" << endl;
return 0;
}


Might I suggest a good book, such as C++ How to Program by Deitel? :cheese:

Jamoe
17-10-2003, 10:03 AM
if u have VS.NET installed or even just the sdk go search read the documentation (should be able to find a link in the start > programs > microsoft .NET Framework SDK folder ). Theres a hello world example in there somewhere.

Also it will depend on which language u intend to use.

Jamoe

Quiddity
17-10-2003, 04:48 PM
isn't C++ How to Program by Deitel for vs 6.0 and such
should i get the one by them called Visual C++.NET: How to Program?

Infernal-Shade
17-10-2003, 08:28 PM
Originally posted by Quiddity
isn't C++ How to Program by Deitel for vs 6.0 and such
should i get the one by them called Visual C++.NET: How to Program?

If you want to learn how to program in C++ using all of the standard libraries, I would get the C++ How to Program book. And because you'll mainly be using standard libraries with that book, your [unmanaged] programs will compile in Visual Studio .NET. If you want to learn how to program in C++ using the Managed Extensions .NET offers, then I would suggest getting the book you mentioned. The direction you want to go is up to you.

ComradeBadger
19-10-2003, 05:52 PM
Originally posted by Infernal-Shade

#include <iostream>

using std::cout;
using std::endl;

int main()
{
cout << "Hello, world!" << endl;
return 0;
}


Might I suggest a good book, such as C++ How to Program by Deitel? :cheese:

Oi! You'll get him into bad programming habits... he should type out std::cout and comment properly, like I had to :dork:


#include <iostream>

int main() // The function main()
{
std::cout << "Hello, world!" << "\n"; // cout (short for output, basically) prints these words to the screen in a black console box
return 0; // since the function main doesn't return a value, it returns zero, or void
}



I hope that helps :)

bobvodka
19-10-2003, 11:15 PM
dear god, over commenting hell. With something that simple at the most you need a comment on the line above and in most cases you dont need line by line commenting. If you was taught that then you've been taught bad habits yourself :)

Epsi
20-10-2003, 05:37 PM
To do a hello world in VS.net, open a new console project, and depending on your language (i'd use managed extensions for C++)

#using <mscorlib.dll>

using namespace System;

int main()
{
Console::WriteLine(S"Hello World!");
return 0;
}

Maybe I should wrap that main() in a class but....

EDIT: Oops, forgot the <> around mscorlib.dll....

ComradeBadger
20-10-2003, 06:56 PM
Originally posted by bobvodka
dear god, over commenting hell. With something that simple at the most you need a comment on the line above and in most cases you dont need line by line commenting. If you was taught that then you've been taught bad habits yourself :)

Actually, I wrote all those comments to explain what everything is doing... :P I only comment on more complex things :P

Quiddity
22-10-2003, 04:32 AM
#include <iostream>

using std::cout;
using std::endl;

int main()
{
cout << "Hello, world!" << endl;
return 0;
}


when i write this code i get an error in .net
the error says:

fatal error C1010: unexpected end of file while looking for precompiled header directive

whats this supposed to mean?

bobvodka
23-10-2003, 02:43 PM
you've got pre-compiled headers turned on in the IDE, look in the project options (cant remember where off hand) to turn them off

Newtware
24-10-2003, 02:56 AM
Compile this.

found here:
http://newtware.net/forums/index.php?showtopic=6

Submerge
25-10-2003, 01:13 AM
wow. i just made a program like that. but not as complicated.

and yes, i compiled it.

one
07-01-2004, 04:40 PM
You can write a hello world program with Microsoft Visual Studio .net in
- C++
- C
- VisualBasic
- C#
- J#

phantomdesign
07-01-2004, 07:02 PM
I was thinking someone made his first automatic forum spammer by the title. Oh well.

babywax
07-01-2004, 08:55 PM
I was thinking someone made his first automatic forum spammer by the title. Oh well.

Funny... I thought the EXACT same thing...

Pendragon
07-01-2004, 10:20 PM
Here's my spin on Hello World:

#include <iostream>

void main()
{
std::cout << "Hello, world!" << "\n"; //"Hello World"
}

SidewinderX
11-01-2004, 01:00 AM
hehe, i'm, not much farther than that.... this was most latest, and most advanced C++ program (though I could tear it up in TI-BASIC :) )


// a small c++ program
#include <iostream>
#include <string>

int main()
{
// ask for name and then start framed greeting
std::cout << " please enter your name. ";

// read the name
std::string name; // defines name
std::cin >> name; //read into the name

//build message
const std::string greeting = "Hello, " + name + "!";

//build 2nd and 4th lines
const std::string spaces(greeting.size(), ' ');
const std::string second = "* " + spaces + " *";

//build 1st and 5th lines
const std::string first(second.size(), '*');

//write it all
std::cout << std::endl;
std::cout << first << std::endl;
std::cout << second << std::endl;
std::cout << "* " << greeting << " *" << std::endl;
std::cout << second << std::endl;
std::cout << first << std::endl;

return 0;
}

CrazyTalk
11-01-2004, 02:20 AM
You guys use a lot of stds in your code.

Pendragon
11-01-2004, 02:37 AM
I know--it's surprising we don't have AIDS by now isn't it? ;)

SidewinderX
11-01-2004, 07:10 AM
the book i'm learning from does it that way, don't blame me.

Sandman
11-01-2004, 09:01 AM
Why do you guys use that? It doesn't change anything, to my knowledge... I just write it like this:


#include <iostream.h>

void main()
{
cout << "Hello world!\n"
<< "How are you doing today?\n"
<< "ME AM FINE!";
//Using one cout statement to do all these quotes is fine...
//But don't do too many!
}


Comments should only be used to help other programmers understand things that aren't readily apparent, or to help you remember things. So, don't do stuff like...


std::cout << "Hello World\n"; //"Hello World"

ComradeBadger
11-01-2004, 12:21 PM
Sandman, 'void main()' is illegal C++

DON'T USE IT GUYS! Seriously, it won't compile.

Pendragon
11-01-2004, 07:22 PM
It's always compiled for me, in every program I've run, and my C++ teacher complemented me on the efficiency of doing that instead of int main() and return 1.

Submerge
11-01-2004, 07:50 PM
i do it like this


#include <iostream.h>

int main()
{
cout << "Hello world." << endl;
return 0;
}

EvNTHriZen
11-01-2004, 10:41 PM
int main() is ANSI compliant... i would suggest using that.

Sandman
21-01-2004, 12:22 AM
Why wouldn't void be ANSI compliant? Using a non-value-returning main is more efficient, and I believe that C++ doesn't care either way. There's no real exception handling done in simple console apps like hello world, so I don't think a value returning function is really necessary.

MrBadger, what compiler do you use?

EvNTHriZen
21-01-2004, 06:24 AM
Well, what i mean is that if use something that isn't ANSI compliant, then it's not guranteed to work in the future. void main() is legal, you can use it. but the industry uses int main(), and, i just learned in sociology that outcasts don't fare to well in society...

BTW.. i don't know why it isn't, just that it's not. :)

Sandman
21-01-2004, 07:27 AM
Of course it will work in the future. Why wouldn't it work in the future? Are you actually trying to get me to use int main instead of void main? It's not like void main is a cheap hack... really what's the big deal? :angel:

EvNTHriZen
23-01-2004, 11:43 PM
Dude, do what you want... I'm not trying to get you to do anything at all.. i am just telling you what ANSI says to do.

bobvodka
24-01-2004, 06:34 PM
Why do you guys use that? It doesn't change anything, to my knowledge... I just write it like this:


#include <iostream.h>

void main()
{
cout << "Hello world!\n"
<< "How are you doing today?\n"
<< "ME AM FINE!";
//Using one cout statement to do all these quotes is fine...
//But don't do too many!
}




Coz that is wrong wrong wrong.
the headers such as <iosteam.h> are for old programs only.
Go out and learn proper C++, drop the .h and use namespaces how you are ment to.