Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-29-2004, 03:20 AM   #1 (permalink)
fnmadog
Registered User
 
fnmadog's Avatar
 
Join Date: Aug 2004
Location: japan
Posts: 6
fnmadog is on a distinguished road
Send a message via AIM to fnmadog
Bran new! Help please!

Sup everyone.

This is probley going to sound a little dumb to you all.

I just started to get into programming. I really don't know why but I thought I'd check it out. Everyone told me to learn C and then C++.

I'm running WindowXP pro. Just so ya know.

1.) What is a good compiler to use? And who do you use them?
a.)I got Dev-C++ can I compile C code in there?
2.) And whats the deal with Visual C++?
3.) I went to this one site and get got the "Hello World" program. Here it is if you don't know what I'm talking about

#include <stdio.h>
main()
{
printf("Hello World\n");
return 0;
}

I can run this from the Dev-C++ compiler but when I do the Command Prompt just opens then closes. I figgered it was in the code but I'm not really sure. Not really sure what I'm doing just kinda fumbling around in the dark.
4.) How can I run this program as if it was just a normal .exe
5.) I some could send me some simple code that would discribe better on what all the different in it met ( like the \n at the end of Hello World or the return 0(why 0?)) or if you could point me to a good site to that tells me these things maybe with some simple sample code on there I could look at.
Any help at all would be very thankful.
fnmadog is offline   Reply With Quote
Old 08-29-2004, 04:55 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
1) Read the last posts by redhead and me, here: http://codenewbie.com/forum/t2184.html
a) Yes.
2) That's a commercial and outdated IDE with RAD capabilities.
3) See below.
4) Since you have XP: Drag the *.exe to the console. Once above the console realease it. Press enter. See what happens.
5) The "\n" is the newline escape code. Basically it prints a newline.
The "0" is optional. Basically it is a good idea to let the application return a value to check wether an app terminated successfully. The most tangible reason on short notice is compatibilty. Besides, returning an exit status is the only defined way according to the ANSI/ISO standards. I wouldn't worry about it in this stage.

Learn from: http://www.cplusplus.com/doc/tutorial/
The style is heavily outdated. Keep in mind that STL is common (nothing special anymore) in modern C++ coding. Remind me of this remark when you reach arrays.

Feel free to post anytime,
Val
__________________

Last edited by Valmont; 08-29-2004 at 05:33 AM.
Valmont is offline   Reply With Quote
Old 08-29-2004, 05:01 AM   #3 (permalink)
fnmadog
Registered User
 
fnmadog's Avatar
 
Join Date: Aug 2004
Location: japan
Posts: 6
fnmadog is on a distinguished road
Send a message via AIM to fnmadog
4) Since you have XP: Drag the *.exe to the console. Once above the console realease it. Press enter. See what happens.

what *.exe ?? and when you say console, you mean the Dev-C++ console?

Thanks for the help. This tutorial seems to touch more on the things I was unsure about.
fnmadog is offline   Reply With Quote
Old 08-29-2004, 05:12 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Oh wait I didn't read you well:

Whilst coding: Use cin.get(); to halt the console whilst in the program environment.
When executing the final executable: The final programs in a MS Windows environment is called an executable. You will recognize applications by observing its extension - *.exe.
Console programs are ran this way:
- Go to Start
- Select Run...
- Type command
- See what pops up. A black screen we call the console. You can execute console programs here. In your case that would be optional. Notice that you will build console based programs only for the moment.
But once again, it is optional. Basically you can execute your code straight from the IDE (Dev-C++). To run it in the IDE you need to add cin.get(); remember?
Remove this line for your final executable. Otherwise other users need to press the enter key followed any key, before the console program exits.
__________________

Last edited by Valmont; 09-01-2004 at 11:29 AM.
Valmont is offline   Reply With Quote
Old 08-29-2004, 05:16 AM   #5 (permalink)
fnmadog
Registered User
 
fnmadog's Avatar
 
Join Date: Aug 2004
Location: japan
Posts: 6
fnmadog is on a distinguished road
Send a message via AIM to fnmadog
Ok this is what I did.
1. opened Dev-C++4
2. opened notepad (wassure if i had to do that, may could have put it in the Dev console.)
3. put this into notepad
// my second program in C++

#include <iostream.h>

int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
return 0;
}

4. saved it as Pro1.cpp
5. opened it in Dev
6. clicked the compile and run button
7. command prompt opens then closes.
8. I add about 200 lines of the same thing on it. Then i could see a glimps of the Hello world! I"m in C++
9. I tried moving the .exe of Pro1 (I seen it made one after I compiled it correctly) into the Dev consule. But that did nothing.

Any additional help would be helpful. For now I'm going to bed. Gnight.
fnmadog is offline   Reply With Quote
Old 08-29-2004, 05:21 AM   #6 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
First get a decent programming environment up. Once again: http://codenewbie.com/forum/t2184.html
Do as I advice. Will make your coding life easier.

Now observe my code:
Code:
#include <iostream.h>

int main ()
{
  cout << "Hello World!";
  cin.get(); //Wait for any keypress (halt console).
  return 0;
}
But be prepared for some modern C++ programming:
Code:
#include <iostream>

int main ()
{
  std::cout << "Hello World!";
  std::cin.get(); //Wait for keypress (halt console).
  return 0;
}
Observe how the .h is missing in the header. Seems we're going to program in standard C++.
Therefore we add std:: before every keyword that can be done in standard C++. You may ignore this for now though. Just be prepared.
__________________
Valmont is offline   Reply With Quote
Old 08-29-2004, 05:30 AM   #7 (permalink)
fnmadog
Registered User
 
fnmadog's Avatar
 
Join Date: Aug 2004
Location: japan
Posts: 6
fnmadog is on a distinguished road
Send a message via AIM to fnmadog
Ah Ha! Monkey see monkey do!

Learn best by exsample.

Thanks again. I promise tomorrow I'll have more questions ^_^
fnmadog is offline   Reply With Quote
Old 08-31-2004, 06:40 PM   #8 (permalink)
Rotkiv
Code Monkey
 
Rotkiv's Avatar
 
Join Date: Apr 2004
Location: Silicon Valley, CA
Posts: 64
Rotkiv is on a distinguished road
Send a message via AIM to Rotkiv Send a message via MSN to Rotkiv
ok, the way i learned is to write 'using namespace std;' at the top (i do it right below the #include stuff, not sure if i have to), therefore i do not have to write 'std::' in front of everything. what's up with this? is there advantages to different methods or does it depend on the IDE/compiler?
Rotkiv is offline   Reply With Quote
Old 09-01-2004, 09:27 AM   #9 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
using namespace std
what's up with this?
You are forcing now everybody else to use this namespace in your code. This defeats the purpose of namespaces.

Although I use it this way my self for this forum - to get things up fast -, I wouldn't promote it. I will stop using the namespace std like this, to give the example.
__________________
Valmont is offline   Reply With Quote
Old 09-02-2004, 03:19 PM   #10 (permalink)
fnmadog
Registered User
 
fnmadog's Avatar
 
Join Date: Aug 2004
Location: japan
Posts: 6
fnmadog is on a distinguished road
Send a message via AIM to fnmadog
what is a namespace? like std? what the perpose of having them?
fnmadog is offline   Reply With Quote
Old 09-02-2004, 04:05 PM   #11 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
A namespace is an entity where a number of coding is defined in. Such a group has a name: a namespace.
In large(r) projects you might want to create your own namespace. In this case, if a collegue uses the same names (for their functions for example) then no name clashes will occur.

The std namespace is the group where the standard C++ is in defined.
Codenewbie has a tutorial on it: http://codenewbie.com/tutorials/900.html
__________________

Last edited by Valmont; 09-02-2004 at 05:25 PM.
Valmont is offline   Reply With Quote
Old 09-03-2004, 04:15 AM   #12 (permalink)
fnmadog
Registered User
 
fnmadog's Avatar
 
Join Date: Aug 2004
Location: japan
Posts: 6
fnmadog is on a distinguished road
Send a message via AIM to fnmadog
thats pretty simple thanks
fnmadog is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 05:21 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting