I need interpret in Console screen in C++

Discussion in 'Programmer's Corner' started by Eng_Bandar, Sep 8, 2010.

  1. Eng_Bandar

    Thread Starter Active Member

    Feb 27, 2010
    50
    1
    Hi all,

    First of all, my problem in Console screen in C++ it is disappear quickly. I use Qt creater 2 to do my code.
    Through my search in web I found the solution for it, put the following inside code
    Code ( (Unknown Language)):
    1.  
    2. [COLOR=#000080]#include[/COLOR][COLOR=#008000]<cstdio>[/COLOR]
    3. getchar[COLOR=#000000]();[/COLOR]
    4.  
    I trid this code and it is work correctly and I could solve Console screen

    Code ( (Unknown Language)):
    1. [COLOR=#000080]#include[/COLOR][COLOR=#008000]<iostream>[/COLOR]
    2. [COLOR=#000080]#include[/COLOR][COLOR=#008000]<cstdio>[/COLOR]
    3. [COLOR=#808000]using[/COLOR][COLOR=#808000]namespace[/COLOR]std[COLOR=#000000];[/COLOR]
    4. [COLOR=#808000]int[/COLOR]main[COLOR=#000000]()[/COLOR][COLOR=#000000]{[/COLOR][COLOR=#008000]//[/COLOR][COLOR=#008000]prints[/COLOR][COLOR=#008000]"m[/COLOR][COLOR=#008000]=[/COLOR][COLOR=#008000]44[/COLOR][COLOR=#008000]and[/COLOR][COLOR=#008000]n[/COLOR][COLOR=#008000]=[/COLOR][COLOR=#008000]77":[/COLOR][COLOR=#808000]int[/COLOR]m[COLOR=#000000],[/COLOR]n[COLOR=#000000];[/COLOR]
    5. m[COLOR=#000000]=[/COLOR][COLOR=#000080]44[/COLOR][COLOR=#000000];[/COLOR][COLOR=#008000]//[/COLOR][COLOR=#008000]assigns[/COLOR][COLOR=#008000]the[/COLOR][COLOR=#008000]value[/COLOR][COLOR=#008000]44[/COLOR][COLOR=#008000]to[/COLOR][COLOR=#008000]the[/COLOR][COLOR=#008000]variable[/COLOR][COLOR=#008000]m[/COLOR]
    6. cout[COLOR=#000000]<<[/COLOR][COLOR=#008000]"m[/COLOR][COLOR=#008000]=[/COLOR][COLOR=#008000]"[/COLOR][COLOR=#000000]<<[/COLOR]m[COLOR=#000000];[/COLOR]n[COLOR=#000000]=[/COLOR]m[COLOR=#000000]+[/COLOR][COLOR=#000080]33[/COLOR][COLOR=#000000];[/COLOR]
    7. [COLOR=#008000]//[/COLOR][COLOR=#008000]assigns[/COLOR][COLOR=#008000]the[/COLOR][COLOR=#008000]value[/COLOR][COLOR=#008000]77[/COLOR][COLOR=#008000]to[/COLOR][COLOR=#008000]the[/COLOR][COLOR=#008000]variable[/COLOR][COLOR=#008000]n[/COLOR]cout[COLOR=#000000]<<[/COLOR][COLOR=#008000]"[/COLOR][COLOR=#008000]and[/COLOR][COLOR=#008000]n[/COLOR][COLOR=#008000]=[/COLOR][COLOR=#008000]"[/COLOR][COLOR=#000000]<<[/COLOR]n[COLOR=#000000]<<[/COLOR]endl[COLOR=#000000];[/COLOR]
    8. getchar[COLOR=#000000]();[/COLOR]
    9. [COLOR=#000000]}[/COLOR]
    But in this code the problem still find
    Code ( (Unknown Language)):
    1.  
    2. [COLOR=#000080]#include[/COLOR][COLOR=#008000]<iostream>[/COLOR]
    3. [COLOR=#000080]#include[/COLOR][COLOR=#008000]<cstdio>[/COLOR]
    4. [COLOR=#808000]using[/COLOR][COLOR=#808000]namespace[/COLOR]std[COLOR=#000000];[/COLOR]
    5. [COLOR=#808000]int[/COLOR]main[COLOR=#000000]()[/COLOR][COLOR=#000000]{[/COLOR][COLOR=#808000]int[/COLOR]a[COLOR=#000000],[/COLOR]b[COLOR=#000000],[/COLOR]c[COLOR=#000000];[/COLOR]
    6. cout[COLOR=#000000]<<[/COLOR][COLOR=#008000]"a[/COLOR][COLOR=#008000]=[/COLOR][COLOR=#008000]"[/COLOR][COLOR=#000000];[/COLOR]cin[COLOR=#000000]>>[/COLOR]a[COLOR=#000000];[/COLOR]
    7. cout[COLOR=#000000]<<[/COLOR][COLOR=#008000]"b[/COLOR][COLOR=#008000]=[/COLOR][COLOR=#008000]"[/COLOR][COLOR=#000000];[/COLOR]cin[COLOR=#000000]>>[/COLOR]b[COLOR=#000000];[/COLOR]
    8. c[COLOR=#000000]=[/COLOR]a[COLOR=#000000]+[/COLOR]b[COLOR=#000000];[/COLOR]cout[COLOR=#000000]<<[/COLOR][COLOR=#008000]"a[/COLOR][COLOR=#008000]+[/COLOR][COLOR=#008000]b[/COLOR][COLOR=#008000]=[/COLOR][COLOR=#008000]"[/COLOR][COLOR=#000000]<<[/COLOR]c[COLOR=#000000];[/COLOR]
    9. getchar[COLOR=#000000]();[/COLOR][COLOR=#000000]}[/COLOR]
    10.  
    Any interpret for this ??!!
     
  2. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    Well with a console application could you not just run it from the console? Then you can see the output ...
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    try a this as the last code line
    1)cin.get();
    2)system ("pause")
    You may also execute your program using Start Without Debugging (CTRL+F5). By doing this, you tell Visual Studio that while this is a debuge .exe. You are not using your debugger. Visual Studio will pause at the end of main() with:
    Press any key to continue... Therefore, you will never need any special code in your program for testing.
     
Loading...