Results 1 to 11 of 11

Thread: console problem

  1. #1

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    console problem

    There is a simple program to print 1 to 10 nos. bu using for lopp. But the console closes before. I a using tubo c++ 3.0. I also added getch() but i will have to press key again and again to print 10 nos.
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  2. #2
    Addicted Member SpS's Avatar
    Join Date
    Jul 2005
    Posts
    201

    Re: console problem

    Use this
    Code:
    #include <iostream>
    #include <limits>
     
    int main() {
       
      // Rest of the code     
      
      //Clean the stream and ask for input
      std::cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
      std::cin.get();
      }
    #Appreciate others by rating good posts !!

    #The Software Peter Principle is in operation when unwise developers "improve" and "generalize" the software until they themselves can no longer understand it, then the project slowly dies.

    #People who are still ignorant of their ignorance are dangerous.

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: console problem

    For Turbo C++
    C++ Code:
    1. #include<iostream.h>
    2. #include<conio.h>
    3.  
    4. int main()
    5. {
    6.       for(int i=1; i<=10; ++i)
    7.       {
    8.             cout<<"Number "<<i<<"\n";
    9.       }
    10.       getchar();
    11. }
    Show Appreciation. Rate Posts.

  4. #4

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: console problem

    @ Harsh
    can i use getch()?
    It does the same job.
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: console problem

    I think a more pertinent question is: why are you using Turbo C++?

  6. #6

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: console problem

    @ Penegate. What other compiler i should use? I used codeblocks,devc++. codeblocks does not suppoert graphics.h header file. Mostprograms are written in turboc++. So i use it to learn c. Actually i m learning c.
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  7. #7
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: console problem

    Quote Originally Posted by vivek_master146
    @ Penegate. What other compiler i should use? I used codeblocks,devc++. codeblocks does not suppoert graphics.h header file. Mostprograms are written in turboc++. So i use it to learn c. Actually i m learning c.
    Theres just so many things wrong with that statement.

    Firstly, CodeBlocks (MingW) doesn't "support" the graphics.h file, because its a Borland file. It has all their other crap in there which can't be understood without the rest of the Borland header files.

    Secondly, "Most programs are written in Turbo C++".. is so hilariously laughable! Where did you get that information from?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: console problem

    Also, Code::Blocks and Dev-C++ aren't compilers.

  9. #9

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: console problem

    I know code blocks and devc++ r not compilers but IDE. But i am learnig c and i have been recommended to use turbo c++ 3.0 as the book i am following also recommend to use turbo c++ for the beginners. Do u know any other good compilers which also has an ide?
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  10. #10
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: console problem

    Theres a CodeBlocks distro which comes with GCC.. I'd stick with that.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  11. #11
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: console problem

    Have a look at Digital Mars they created the D language and seem to have quite a nice C/C++ compiler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width