2 quick questions

This is a discussion on 2 quick questions within the C Programming forums, part of the General Programming Boards category; Can anyone tell me how to pause the screen, say like after some output? ie. Press any key to continue--- ...

  1. #1
    Unregistered
    Guest

    2 quick questions

    Can anyone tell me how to pause the screen, say like after some output? ie. Press any key to continue--- I am guessing it uses stdin to some extent unless there is a shortcut.

    Also, which library is the MIN() function stored in? (function that finds the minimum of 2 specified values).

    Thanks.

  2. #2
    D3T
    D3T is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    12
    for the push any key to continue..
    Code:
    #include <conio.h> /* You will need this for getch(); */
    #include <iostream.h> /* and this for cout . you could use printf */
    {
    ...
    cout << "Push any key to continue...";
    getch();
    /*What to do after key is pressed */
    ...
    }
    This should work. If you dont have the two headers, i can send them to u.
    (I'm d3t@barrysworld.com)

    This works in Borland Turbo C++ (pwned). It should work anyway, since getch() and cout are unlikely to be advanced beyond the scope of C.
    [D3T]
    Borland Turbo C++ 3.0 For Dos

    *
    do { war(); } while (nations == hostile);

    ... The best way to prevent wars is to have them.

  3. #3
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    min() and max() are found in the header <stdlib.h> in msvc, dunno if their ansi standard though, probably not.
    Its easy to find header files for functions, all you have to do is try different headers until the compiler recognizes the function.

    cout << "Push any key to continue...";
    Will that work in c, wouldn't have thought so. Use printf instead
    Code:
    #include <stdio.h>
    #include <conio.h> /* for getch */
    
    printf("Press any key to continue.");
    getch();
    However getch isn't ansi standard so you may not have it
    Last edited by C_Coder; 03-02-2002 at 09:28 AM.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  4. #4
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    dev-c++ defaults to a template program with a system("pause"); call.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    This would be ANSII-conform:
    Code:
    void pause(void)
    {
     char c;
     puts("press enter  to continue:");
     c=fgetc(stdin);
    }
    klausi
    Last edited by klausi; 03-02-2002 at 09:57 AM.
    When I close my eyes nobody can see me...

  6. #6
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    or
    Code:
    void pause(void)
    {
     puts("press enter  to continue:");
     fgetc(stdin);
    }
    You don't have to use return values, save a whole lot of memory
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    Thanks!
    When I close my eyes nobody can see me...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Two quick questions about open file dialog boxes
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 04-05-2005, 09:49 AM
  2. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  3. A quick question(s)
    By EvBladeRunnervE in forum C++ Programming
    Replies: 3
    Last Post: 02-17-2003, 09:39 PM
  4. Quick Inheritance questions
    By VanJay011379 in forum C++ Programming
    Replies: 1
    Last Post: 07-22-2002, 10:21 AM
  5. A few quick questions...
    By cpp4ever in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2001, 10:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21