Tweak3D.Net
Save?
Not Registered Yet? Go here.
Xoxide Computer Mods Contact the webmaster to purchase this spot on the web site
Join The Cult Tweakers Image Gallery Donate Search Today's Posts Mark Forums Read

Welcome to Tweak3D

This is an open forum about tech stuff, games, and cars. Register to access all forums, and to hide this ad and others.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-18-2005, 10:31 PM   permanent link to #1
 
NoPunIntended's Avatar
NoPunIntended
Senior Member
 
Join Date: Aug 2005
Location: ConnectiCut
Posts: 838 (#99 )
Thanked 0x in 0 posts

I currently purchased Microsoft Visual C++.net Standard version 2003 for my Computer Science class. I can make a simple program, but the assignment that my teacher gave us, I cannot figure out. He wants use to create a program that we can print. Here is the code he gave us.

//File: welcome.cpp - Program to print a welcoming message

#include <iostream.h>
#include <conio.h>

int main (void)
{
cout << "Welcome to CSE 123! \n";
getch();
return 0;
}

How do I go about starting up a program to make this code work out the way I want it to. I am totally lost. I need step by step intructions if someone could help. I really appreciate it.
NoPunIntended is offline Ignore this User   Reply With Quote
Yesterday, 05:30 PM   #2
 
 


Google is online (hide)  
Old 09-18-2005, 10:46 PM   permanent link to #2
 
j0k3r's Avatar
j0k3r
El Chupacabra
 
Join Date: Jan 2005
Location: Phoenix
Posts: 2,013 (#49 )
Thanked 16x in 9 posts

You are going to create a new console application, or just create a .cpp file, put that code in there, compile it and you are done.

j0k3r is offline Ignore this User   Reply With Quote
Old 09-19-2005, 06:10 AM   permanent link to #3
 
NoPunIntended's Avatar
NoPunIntended
Senior Member
 
Join Date: Aug 2005
Location: ConnectiCut
Posts: 838 (#99 )
Thanked 0x in 0 posts

I've done that, but its telling me there is an error. My output says,

"------ Build started: Project: CSE123, Configuration: Debug Win32 ------

Compiling...
stdafx.cpp
Compiling...
CSE123 5.cpp
CSE123 5.cpp(12) : fatal error C1010: unexpected end of file while looking for precompiled header directive
AssemblyInfo.cpp
CSE123.cpp
Generating Code...

Build log was saved at...
CSE123 - 1 error(s), 0 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped"

Hmm... what should I do?

NoPunIntended is offline Ignore this User   Reply With Quote
Old 09-19-2005, 10:35 AM   permanent link to #4
 
superlinuxman's Avatar
superlinuxman
3D+Linux Master
 
Join Date: Jan 2005
Location: Santa Monica, CA
Posts: 1,134 (#85 )
Thanked 0x in 0 posts
Send a message via AIM to superlinuxman

Quote:
Originally Posted by NoPunIntended
//File: welcome.cpp - Program to print a welcoming message

#include <iostream.h>
#include <conio.h>

int main (void)
{
cout << "Welcome to CSE 123! \n";
getch();
return 0;
}
Your first mistake: You didnt tell the compiler that cout is part of the standard namespace. There are two ways to do this.

put this line below your #includes

namespace std; //i think thats the syntax its been a while

or

put the std namesace indacator before each cin/cout/ or anything else your using in that namespace

std::cout

Your 2nd problem is that you not using the getch(); function correct
this means you dont understand it so do everyone a favor and use google.com

Oh i think your using the wrong header for getch(); too i believe its curses.h

superlinuxman is offline Ignore this User   Reply With Quote
Old 09-19-2005, 10:59 AM   permanent link to #5
 
thadood's Avatar
thadood
I Am The Black Wizards
 
Join Date: Jan 2005
Location: Horn Lake, MS
Posts: 3,488 (#24 )
Thanked 4x in 4 posts
Send a message via ICQ to thadood Send a message via AIM to thadood Send a message via MSN to thadood Send a message via Yahoo to thadood

#include <iostream>
using namespace std;

int main()
{
cout << "Stuff here" << endl;
return 0;
}

I don't even know what getch() is, but that's the same exact thing that you have written, just in a bit more simplified terms.
I suggest trying DevCPP; no need to create a new project for a simple 7 line program.

thadood is offline Ignore this User   Reply With Quote
Old 09-19-2005, 01:00 PM   permanent link to #6
 
Wedge_'s Avatar
Wedge_
Rogue One
 
Join Date: Jan 2005
Location: Scotland
Posts: 1,016 (#88 Last month's rank was 87)
Thanked 0x in 0 posts

Quote:
Originally Posted by superlinuxman
Your 2nd problem is that you not using the getch(); function correct
this means you dont understand it so do everyone a favor and use google.com

Oh i think your using the wrong header for getch(); too i believe its curses.h
This is Windows we're talking about - try including curses.h and see what happens conio is the correct header AFAIK. What he's using it for there is to wait for a keypress before exiting the program, because it will usually just drop you straight back into the IDE without giving you time to read the output.

NoPunIntended: your problem is probably just that you've removed the
Code:
#include "stdafx.h"
line from your CSE123 5.cpp file - add that back in and things should work. stdafx.cpp and stdafx.h aren't actually necessary for a program like this, so you could also just remove them from your project altogether.

Per Ardua Ad Astra
Wedge_ is offline Ignore this User   Reply With Quote
Old 09-19-2005, 01:38 PM   permanent link to #7
 
thadood's Avatar
thadood
I Am The Black Wizards
 
Join Date: Jan 2005
Location: Horn Lake, MS
Posts: 3,488 (#24 )
Thanked 4x in 4 posts
Send a message via ICQ to thadood Send a message via AIM to thadood Send a message via MSN to thadood Send a message via Yahoo to thadood

Quote:
Originally Posted by Wedge_
What he's using it for there is to wait for a keypress before exiting the program, because it will usually just drop you straight back into the IDE without giving you time to read the output.
system("pause");

Works just like this getch you describe =)

thadood is offline Ignore this User   Reply With Quote
Old 09-19-2005, 02:26 PM   permanent link to #8
 
Wedge_'s Avatar
Wedge_
Rogue One
 
Join Date: Jan 2005
Location: Scotland
Posts: 1,016 (#88 Last month's rank was 87)
Thanked 0x in 0 posts

Yep, but getch() is a better way to do it, because you're just calling a function, not some external command. You also have more control over things - with "pause", you'll always get the "Press any key to continue" message displayed, which you might not want depending on your app.

Per Ardua Ad Astra
Wedge_ is offline Ignore this User   Reply With Quote
Old 09-21-2005, 10:50 PM   permanent link to #9
 
funkgab's Avatar
funkgab
Tweak Minion
 
Join Date: Jan 2005
Location: Los Angeles, California
Posts: 1,203 (#80 )
Thanked 0x in 0 posts
Send a message via AIM to funkgab

#include <iostream>
#include <stdlib.h>

using namespace std;

int main( int argc, char** argv ) {
cout << "Welcome to CSE 123!" << endl;
system( "pause" );
return 0;
}

try that
funkgab is offline Ignore this User   Reply With Quote
Reply

Login to reply. Sign-up here.



1 people are viewing this thread! (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
PC crash, video card suggestions needed! MSP Tech 20 07-21-2006 07:57 PM
New keyboard and mouse needed -UPDATED with initial thoughts Lazaredz Tech 11 07-21-2006 07:24 PM
Resume Help needed Please!!!!! Alpha OT Graveyard 8 06-06-2006 06:16 PM
little assistance needed Jamsan OT Graveyard 0 06-04-2006 11:59 PM
Upgrading my PC soon! Advice needed. Chris Tech 5 05-15-2006 10:17 PM


All times are GMT -7. The time now is 11:18 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0
©Tweak3D.Net 1998-2008Ad Management by RedTyger