Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 2nd, 2004, 7:38 AM   #11
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
It would wait for you to type an input before the window closed.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Oct 2nd, 2004, 7:42 AM   #12
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5 TecBrain is on a distinguished road
yes but the window is closing after adding the new value of a:

cin >> a;
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old Oct 2nd, 2004, 8:17 AM   #13
Ravilj
Programmer
 
Ravilj's Avatar
 
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 5 Ravilj is on a distinguished road
this works for me:
#include <iostream>

using namespace std;

int main()
{
	float a,b;

	cout << "Enter degrees celcius: ";
	cin >> a;	
	cout << "Degrees Fahernheit: " << (a*1.8) + 32 << endl;

	system("PAUSE");

	return 0;
}
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005!
Ravilj is offline   Reply With Quote
Old Oct 2nd, 2004, 8:39 AM   #14
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5 TecBrain is on a distinguished road
yah, that works for me too.

Can i ask what is the system("PAUSE"); for.
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old Oct 2nd, 2004, 9:41 AM   #15
Pat
Newbie
 
Pat's Avatar
 
Join Date: Sep 2004
Location: Canada
Posts: 23
Rep Power: 0 Pat is on a distinguished road
Send a message via AIM to Pat Send a message via MSN to Pat
Whatever you write in the system() parentheses is echoed as if it was typed in a DOS command prompt, so what it would do is issue the "PAUSE" command, which effectively stops it from doing whatever it's doing and displays the message

"Press any key to continue . . ."
Pat is offline   Reply With Quote
Old Oct 2nd, 2004, 10:28 AM   #16
Ravilj
Programmer
 
Ravilj's Avatar
 
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 5 Ravilj is on a distinguished road
TecBrain, try this quick remove the system("PAUSE") and run it and see what happens, just out of interest...
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005!
Ravilj is offline   Reply With Quote
Old Oct 2nd, 2004, 4:58 PM   #17
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5 TecBrain is on a distinguished road
That’s why I asked, because when I moved out the:

system("PAUSE");


The output did not appear, as soon as I entered the input the Dos screen goes away. So I was wondering if that code would be allowing the output to appear.


Thanks in all cases guys, you were helpful.

I will be asking allot of question as the time passes. :unsure:
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old Oct 2nd, 2004, 5:19 PM   #18
Ravilj
Programmer
 
Ravilj's Avatar
 
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 5 Ravilj is on a distinguished road
interesting... yeah than just use that at the end of all your windows console programs to see the output.

Ok I downloaded Dev C compiler, when you select a new console application it sets out the followign code by default:

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

using namespace std;

int main(int argc, char *argv[])
{
 
 system("PAUSE");	
 return 0;
}

So it seems that Visual Studio adds that in for you and with dev c its left up to you to add it in.
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005!
Ravilj is offline   Reply With Quote
Old Oct 2nd, 2004, 6:53 PM   #19
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 556
Rep Power: 5 Benoit is on a distinguished road
Here's my Celsius to Fahrenheit converter written in C

#include<stdio.h>

main()
{
    float c,f;
    printf("Celsius to Fahrenheit\n\n\n");
    printf("Enter Celsius value: ");
    scanf("%f",&c);
    f=(1.8*c)+32;
    printf("\n%.0f C = %.0f F\n", c,f);
    return 0;

}
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:08 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC