C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 31st, 2005, 11:55 PM
PreemptFallacy PreemptFallacy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 14 PreemptFallacy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 48 m 42 sec
Reputation Power: 0
Question A beginer's question

Hello everyone. I'n new to C, but even newer to this community. This is my first post. Here's my problem (you knew that was coming.) I feel that I understand the very, very basics of C, but every time I try to execute a compiled program it opens a blank, black screen and then returns to my compiler. I think it might be because I don't have some of the "standard library" Is that even possible. Any comments are greatly appriciated!

Reply With Quote
  #2  
Old September 1st, 2005, 07:47 AM
kolokol kolokol is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 18 kolokol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 3 m 5 sec
Reputation Power: 0
//Basic program template for chapter one using int main()
//
//insert description here
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
//insert code here

//end of inserted code

//wait until user is ready before terminating program
//to allow the user to see the program results
system("PAUSE");
return 0;
}


This is the basic template from a book into which ive been shoving my code. Do you have any include files?
Does even getting it to write some text fail?

Reply With Quote
  #3  
Old September 1st, 2005, 10:14 AM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 4
Send a message via AIM to Geo.Garnett
-PreemptFallacy-

yes system ("PAUSE") works for me too Kolokol but you could just create a variable like this as well, but basically its all in your personal preference =Þ i prefer this way most of the time.

Code:
int main(void)
{
int exit;

code

cin>>exit
return 0;
}

By the way PreemptFallacy the program opens then closes "in most cases" because your code is finished, the computer went through every line of code and returned 0 and then closed the window,(this is if you are running the program for the compiler that is!!!)(If you do not have the compiler open and you try to run the program and then it shuts off and goes to the compiler than you probably have an error in your code itself and needs to be debuged!!!) If there were something wrong most compilers would let you know there was a break and ask you if you wanted to debug, but I only have two compilers so Im not to sure on that one. =) I wouldn't think it is your compilers libraries because if it was that, you usually aren't able to compile the program and run it, so I think your ok there.

Last edited by Geo.Garnett : September 1st, 2005 at 03:02 PM. Reason: Forgot something important

Reply With Quote
  #4  
Old September 1st, 2005, 06:32 PM
MichaelSoft MichaelSoft is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: The Netherlands
Posts: 121 MichaelSoft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 20 sec
Reputation Power: 4
Personally I find it better to open a command window (start, run, "cmd", enter ... that is, for Windows XP ). Then move to the directory of the executable, and enter the name.

This will show you the output without changing the code and pressing a key to finish your program every time...
Just keep the command window open.

Reply With Quote
  #5  
Old September 2nd, 2005, 01:25 AM
PreemptFallacy PreemptFallacy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 14 PreemptFallacy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 48 m 42 sec
Reputation Power: 0
Quote:
Originally Posted by kolokol

Do you have any include files?
Does even getting it to write some text fail?


Yes, I do have include files, and generally speaking, no it does not write text. Thanks for your help!

Reply With Quote
  #6  
Old September 2nd, 2005, 01:30 AM
PreemptFallacy PreemptFallacy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 14 PreemptFallacy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 48 m 42 sec
Reputation Power: 0
Quote:
Originally Posted by Geo.Garnett
By the way PreemptFallacy the program opens then closes "in most cases" because your code is finished, the computer went through every line of code and returned 0 and then closed the window,(this is if you are running the program for the compiler that is!!!)(If you do not have the compiler open and you try to run the program and then it shuts off and goes to the compiler than you probably have an error in your code itself and needs to be debuged!!!) If there were something wrong most compilers would let you know there was a break and ask you if you wanted to debug, but I only have two compilers so Im not to sure on that one. =) I wouldn't think it is your compilers libraries because if it was that, you usually aren't able to compile the program and run it, so I think your ok there.


I use Dev-C++, if that helps you any. This is the code I tried to run. Very simple, just to see if it would work.

#include <stdio.h>
int main()
{
printf("Output here."\n");
return 0;
}

I ran this through a command line, not my compiler and got the same result; I did however find several files which are considered to be "standard" as a sub-folder, so I know that's not the problem. Any other suggestions?

Reply With Quote
  #7  
Old September 2nd, 2005, 01:39 AM
PreemptFallacy PreemptFallacy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 14 PreemptFallacy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 48 m 42 sec
Reputation Power: 0
Quote:
Originally Posted by MichaelSoft
Personally I find it better to open a command window (start, run, "cmd", enter ... that is, for Windows XP ). Then move to the directory of the executable, and enter the name.

This will show you the output without changing the code and pressing a key to finish your program every time...
Just keep the command window open.


Thank you so much!! I did this with the simple output here program, and it displayed "output here" and didn't terminate. Thanks!!

Reply With Quote
  #8  
Old September 5th, 2005, 09:43 AM
MichaelSoft MichaelSoft is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: The Netherlands
Posts: 121 MichaelSoft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 20 sec
Reputation Power: 4
You're welcome.
It is always frustrating when things don't go as you would expect and you can't find the reason.

Good luck with the rest of your C development, and ... if you bump into any other problems: you're not so new to this community anymore

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > A beginer's question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT