Jump to content


Photo

help with c++


  • This topic is locked This topic is locked
8 replies to this topic

#1 sabeeh

sabeeh

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 18 December 2005 - 03:15 PM

can someone tell me how to get the out put in c++, like after making something in c++ how can i see wat i made. i am new to c++ and still learning so can u help me plz. :D :) :) :( :( :(

#2 PSgirl

PSgirl

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 2,056 posts
  • Gender:Female

Posted 18 December 2005 - 03:27 PM

If I've understood you right, you want to show something on the screen, don't you?

First of all, include this line just after the includes at the top of the program:
using namespace std;

Then, in your program, if you want to show a message, just use:
cout << "This message will appear on the screen";

And if you want to show the value of some variable, for example:

int tutorials = 5;
Your program here...
cout << "The number of tutorials is: " << tutorials;
It'll show: The number of tutorials is: 5

Hope it helps :D

#3 sabeeh

sabeeh

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 18 December 2005 - 03:38 PM

even after typing this how do i see the output screen that i need to know?

#4 PSgirl

PSgirl

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 2,056 posts
  • Gender:Female

Posted 18 December 2005 - 03:59 PM

You should compile the program using a compilator.
I use Dev-C++, it's free.
Save your program as example.cpp for example, and then compile it using a compilator.
If the program is correct, an *.exe file will appear where you've saved the *.cpp one.
To execute the program, just open the *.exe file :lol:

Edited by PSgirl, 18 December 2005 - 04:27 PM.


#5 sabeeh

sabeeh

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 18 December 2005 - 04:23 PM

thank you varrrrrrrrryyyyyyy much it works now :lol:

#6 Indigo

Indigo

    Official Alien

  • Members
  • PipPipPip
  • 617 posts
  • Gender:Male
  • Location:Trondheim, Norway
  • Interests:Computing in general, especially design and programming of all kinds.

Posted 19 December 2005 - 04:38 AM

Thougth I´d add something, ´cause when I compile only text, the window pops up and closes immidiately, before i even can see what the output is. So, at the end of my code, I simply insert:

system("pause");

Then the program waits for user to press a key before it shuts down.

#7 PSgirl

PSgirl

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 2,056 posts
  • Gender:Female

Posted 19 December 2005 - 06:01 AM

Yes, that happens sometimes.
You can also use
cin.get(); cin.get()
at the end of your code, so the window remains open until you press a key two times.

#8 AC-Milan

AC-Milan

    Young Padawan

  • Members
  • Pip
  • 98 posts

Posted 19 December 2005 - 11:38 AM

And you can also use :
#include <iostream.h>
#include <conio.h>
int main()
{
cout<<"Text"<<endl;
getch();
return 0;
}


#9 PSgirl

PSgirl

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 2,056 posts
  • Gender:Female

Posted 19 December 2005 - 02:00 PM

Yes, lots of possibilities there :P

I'm closing this topic as the original question has been answered.
sabeeh feel free to start another topic if you have any other issues with C++ ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users