DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   output window for c++!!! help!! (http://www.daniweb.com/forums/thread109681.html)

rockbd Feb 18th, 2008 10:50 am
output window for c++!!! help!!
 
hello!! i am a new programmer!! i started with turbo c 4.5.
just installed borland Turbo c++. the used same codes as 4.5 but got problem with output screen. i cant see the programs output screen after the program ends!!
can anybody tell me how to active it?

niek_e Feb 18th, 2008 10:53 am
Re: output window for c++!!! help!!
 
Turbo C++ is really outdated... You could try downloading a newer (free) IDE like Visual Studio Express or Bloodshed .

For your problem:

Put a
std::cin.get();
just before you
return 0;
.
(Or
getchar()
when using C)

Niek

rockbd Feb 18th, 2008 11:38 am
Re: output window for c++!!! help!!
 
this is a new turbo c++ compiler released in sept 2006. unfortunately your code causes an error

[C++ Error] Unit1.cpp(27): E2316 'cin' is not a member of 'std'

here's the full code:



#include<stdio.h>

int main()
{
float s=0,n=0,k=1;

printf("Enter the value of n\n");
scanf("%f",&n);

do
{
s=(s+(1/k));
k=(k+1);
}
while(n>=k) ;



printf("The sum = %f",s);

std::cin.get();
return 0;


}

VernonDozier Feb 18th, 2008 11:45 am
Re: output window for c++!!! help!!
 
You have not included the library that cin comes from (iostream) and you have not told the compiler that when you use the word "cin", you are referring to the function "cin" from iostream.

Try adding these two lines at the top of your program:
#include <iostream>
using namespace std;

edit: You already did the "std" part in the code body. Sorry. You just need the first line.

rockbd Feb 18th, 2008 12:01 pm
Re: output window for c++!!! help!!
 
thanks. but the problem was fixed by this :

cin.ignore().ignore() ;

thanks anyway. :)

Duoas Feb 18th, 2008 1:03 pm
Re: output window for c++!!! help!!
 
I would not hire you if I saw that code.

Listen to VernonDozier and niek_e. They know what they are talking about.

Your program is a C program (not C++), so you shouldn't be using C++ stuff in it.


All times are GMT -4. The time now is 10:25 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC