There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
uhh......can't write hello world?!?!?!


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
semidevil's Avatar
Senior Member with 178 posts.
 
Join Date: Jun 2002
05-Jul-2002, 08:27 PM #1
uhh......can't write hello world?!?!?!
to you guys, this should be easy, but to a newbie, this is like rocket science.


So I just brought a book today. called Teach yourself C++. It came w/ the Dev C++ compiler, which I installed. I did exactly what the book told me to do I put in the HelloWorld code, and compiled it. It ran completely fine. But when I exectuted it, I didn't get an output. All that happened was my compiler minizmized really really quick, and popped back up. no output, no nothing.

But.........for simplicity sake, I saved my projects on my desktop, so after trying to execute it, 3 or 4 new files appeared on my desktop. That's all I got........

hmm....so if I can't even run the very first program, it's kind of pointless to go on further into the book no?

help
Davey7549's Avatar
Moderator with 11,913 posts.
 
Join Date: Feb 2001
Location: Mukwonago Wisconsin USA
Experience: Advanced
05-Jul-2002, 08:47 PM #2
Semidevil
I do not know C++ so I cannot help with actual code but I do know your desktop is a unique animal and can cause many unusual problems when is code sitting on it and being executed from it. You may try creating a folder and moving all the code into the folder then try executing it from there. You may also consider moving the folder to your Documents.
Just a thought!
Dave
__________________
__________________
__________________

If my help provided a solution to your problem please click "Here" and consider making a donation to help offset the cost of running our Free Tech support site!

If you have problems with above link you can also donate directly by using "This Link".

Thank you for your support!

Davey
semidevil's Avatar
Senior Member with 178 posts.
 
Join Date: Jun 2002
05-Jul-2002, 08:59 PM #3
hi Dave,

yea, it turns out that it didn't work. I created a folder inside my C drive called "codes" and saved my projects in there.

Again, the program compiled fine, but when it came time to actually run it, all my compiler did was minimize really really quick and maximize back on screen.

again, 6 files appeared on my codes folder

Project.dev
Project~2.exe
Project1.cpp
Project1.o
rsrc.o
Rsrc.rc

dont know........

heck, here is the code that I put.
===========================================

#include <iostream>

int main()
{
std::cout << "hi\n";
return 0;

}
=================================
eddie5659's Avatar
Computer Specs
Moderator with 18,344 posts.
 
Join Date: Mar 2001
Location: Bradford, England
05-Jul-2002, 09:11 PM #4
Hiya

I have used Borland to learn how to compile, so this is the basics for the hello World:

You say you use this:

==============================================

#include

int main()
{
std::cout << "hi\n";
return 0;

}

==============================================

Now, is that it? What you don't have in there is a getch. For example, try this. Also, not sure if you have the standard #includes in, but I'll put a simple program in:

==============================================

#include condefs.h
#include stdio.h
#include stdlib.h
#include iostream.h
#include conio.h
#pragma hdrstop


int main(int argc, char **argv)
{
cout << "hello World!" << endl;

cout << endl << "Press any key to continue...";
getch();
return 0;
}

==============================================

*edit* Okay. The words condefs.h, stdio.h, stdlib.h, iostream.h, conio.h and hdrstop need to have the <'s and >'s surrounding them.

There are 2 spaces in front of the cout to return. In other words, as I can't get the spaces to post, just put the {'s in, and the beginning of each line in between, add 2 spaces. if you get my drift

As I say, the #includes may already be set up, but the getch produces a keystroke type of effect. Also, you don't have any endl's in there.

Regards

eddie
__________________
Just go with the flow, like a twig on the shoulders of a mighty stream

Last edited by eddie5659 : 07-Jul-2002 06:16 PM.
semidevil's Avatar
Senior Member with 178 posts.
 
Join Date: Jun 2002
05-Jul-2002, 09:20 PM #5
hmm, do you tink it's the compiler? Is there a different I should/could try?

Eddie,

I copied your code onto my compiler, and it got the same result....
eddie5659's Avatar
Computer Specs
Moderator with 18,344 posts.
 
Join Date: Mar 2001
Location: Bradford, England
05-Jul-2002, 09:23 PM #6
Whats the complier you're using?

In the book, what does it suggest for the Hello world program? Was that all it gave, when you posted the code.


Did you put those spaces in, that I tried to mention?

eddie
eddie5659's Avatar
Computer Specs
Moderator with 18,344 posts.
 
Join Date: Mar 2001
Location: Bradford, England
05-Jul-2002, 09:24 PM #7
Hang on, there's bits missing in mine

I'll edit it, so look back at it in a minute

Okay, all done

eddie
semidevil's Avatar
Senior Member with 178 posts.
 
Join Date: Jun 2002
05-Jul-2002, 10:16 PM #8
hm........that's wierd......still the same problem. I dno't know.........I"m getting frustrated now
DJ P@CkMaN's Avatar
Senior Member with 414 posts.
 
Join Date: Aug 2001
Location: Burpengary, QLD, Australia
06-Jul-2002, 06:31 AM #9
what OS are you using? i have the same problem in WinXP and im not sure if this would happen in other OSes. try copying the EXE file (Project~2.exe) to C:\ and click Start>Programs>Accessories>Command prompt or MS-DOS Prompt and type

C:\Project~2.exe

and it should work fine

good luck
IMM's Avatar
IMM IMM is offline
Distinguished Member with 3,157 posts.
 
Join Date: Feb 2002
06-Jul-2002, 06:06 PM #10
Eddie - is this what you're chasing?
----------
#include&nbsp;&lt;condefs.h&gt;
#include&nbsp;&lt;stdio.h&gt;
#include&nbsp;&lt;stdlib.h&gt;
#include&nbsp;&lt;iostream.h&gt;
#pragma&nbsp;hdrstop

int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv)
{
&nbsp;&nbsp;cout&nbsp;<<&nbsp;"hello&nbsp;World!"&nbsp;<<&nbsp;endl;

&nbsp;&nbsp;cout&nbsp;<<&nbsp;endl&nbsp;<<&nbsp;"Press&nbsp;any&nbsp;key&nb sp;to&nbsp;continue...";
&nbsp;&nbsp;getch();
&nbsp;&nbsp;return&nbsp;0;
}
-------------
or more simply
Code:
#include &lt;condefs.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;iostream.h&gt;
#pragma hdrstop

int main(int argc, char **argv)
{
  cout << "hello World!" << endl;

  cout << endl << "Press any key to continue...";
  getch();
  return 0;
}
You can view the source on this page to see how I did it.
As a side note - those spaces shouldn't matter to the compiler at all - they are merely readability issues and unless he's using precompiled headers and you feed the hdrstop a filename - I'd leave it out.

Last edited by IMM : 06-Jul-2002 06:43 PM.
DJ P@CkMaN's Avatar
Senior Member with 414 posts.
 
Join Date: Aug 2001
Location: Burpengary, QLD, Australia
07-Jul-2002, 08:13 AM #11
hmmm.. ur making a simple task WAY more complicated. as i am new to C++ as well i understand what hes going through and you guys cant be helping
eddie5659's Avatar
Computer Specs
Moderator with 18,344 posts.
 
Join Date: Mar 2001
Location: Bradford, England
07-Jul-2002, 06:15 PM #12
Sorry, DJ P@CkMaN, just lost myself in the moment. First reply in Developement....ever

semidevil:

I have Win2000, and the code that I put worked well. Whats the company that made the compiler?

The Project1.cpp looks like its the code, or at least the name of the program that you are trying to run.

hang on, just realised I have something missing in my code. I'll edit it again, so try it once more. left out conio.


eddie
__________________
Just go with the flow, like a twig on the shoulders of a mighty stream
semidevil's Avatar
Senior Member with 178 posts.
 
Join Date: Jun 2002
07-Jul-2002, 08:49 PM #13
hmm.......I don't know. the compiler came w/ my book, and it is called Dev C++. I think you can d/load it too.

but yea, I dont' know. I still can't get hello world. The code HAS to be right because I just copied right out of the book.

btw, when you install a compiler on your pc, is that all you need to do? aer there special settings that I need to configure before getting it to work properly?

I dont' know, could there be a problem somewhere there?
eddie5659's Avatar
Computer Specs
Moderator with 18,344 posts.
 
Join Date: Mar 2001
Location: Bradford, England
07-Jul-2002, 09:08 PM #14
Hiya

When I installed mine from Borland, that was all I had to do.

The bit of code that you have given right at the beginning: was that all that it said in the book?

Also, were the #include's already shown in the compiler?

eddie
semidevil's Avatar
Senior Member with 178 posts.
 
Join Date: Jun 2002
07-Jul-2002, 09:23 PM #15
hmmm.......yea, that code was it. just those tiny 5 or 6 lines. As of matter of fact, the stuff that YOU typed got my head spinning! haha, j/k.

as for the #include <iostream>, no, I had to type that in myself....the project started out as a blank application.

as for any configurations, the reason I asked is that in my java class, I had to configure like my path in autoexec.bat and stuff like to get it to run. So I was wondering if C had anything like that all....
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:46 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.