How do I pause C command-line program?

Hello. I'm writing a little command-line game app in C and I'm curious about how I can pause the program to wait for the user to hit return. I want the user to need to hit return (or having to hit any key would work too) to make the program continue, and I would like the key that was hit not to appear on the screen -- just a simple sort of "hit any key to continue" type thing. In C++ I think we used something like system("Pause") or something like that -- don't really remember, but any help here will be greatly appreciated. Thanks!

Something like this will print a prompt, then wait for a keystroke:
printf("Hit any key to continue> ");
getchar();
However in a console application, it's not so easy to prevent the user's keystrokes from being echoed. There are ways to turn the echo off for the keystroke then restore it, but those can depend on the environment. I'd need to know whether you're running your program in an Xcode console window, a Terminal window, or elsewhere. In short, don't go there unless it's quite important to you. The above prompt will show any chars that are keyed-in as text after the arrow, which is what a user would expect.
Hope that helps!
- Ray

Similar Messages

  • How to call Operating System commands / external programs from within APEX

    Hi,
    Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
    E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
    c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
    Any pointers will be greatly appreciated.
    Thanks & Regards,

    Hi Guys,
    I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
    However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
    sqlplusw.exe user/password@database @script1.sql
    sqlplusw.exe user/password@database @script2.sql
    sqlplusw.exe user/password@database @script3.sql
    sqlplusw.exe user/password@database @script4.sql
    What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
    Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
    Any help will be greatly appreciated.
    Thanks & Regards,

  • Uninstalling Command Line Programs

    I've searched these forums and the internet for an answer to this, but there doesn't seem to be anything out there, so I hope this will be helpful to others as well.
    I have some open source command line programs that I downloaded, compiled, and installed as part of some exercises I was doing in a book on open source GIS (geographic information systems). What I want to know is how do I remove those programs? I can find references for compiling and installing these types of programs all over the internet, but nothing about removing or uninstalling them.
    Also, any ideas for good, up-to-date references on learning Unix in Mac OS X would be appreciated too. I'd like to get more into open source GIS, but from the research I've been doing, knowing Unix would help a lot.

    What process did you use to compile and install? Was it a configure, make, make install sequence, which is fairly common? If so, go back to the directory where you did that, and try, for example, 'make uninstall'. This might work.
    Look for output files from the compile and install process (perhaps config.log) that might tell you where files will be installed. Perhaps in /usr/local?
    Is there a README or INSTALL file that came with the source code? Documentation about what was installed where might be there.
    If worst comes to worst, and you're really determined, you could repeat the compile and install steps, but with a before and after listing of all the files in your system, and compare the listings. Or use the find command immediately after the reinstall, looking for recently created or changed files (the 'mtime' option or similar).

  • How to set SAXParser at command-line interface to create a large XML file

    Hi,
    I am trying to create a large XML file (more than 50 MB) by selecting from Oracle database but failed because of "out of memory" error. According to "Oracle XML Developer Guide", we should use SAXParser to parsing a large XML file. But there is no example to show how to set SAXParser at command-line
    Following is what I use to get xml files. It works only when the file is small.
    java OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
    "jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
    When I set SAXParser at the way below,
    java oracle.xml.parser.v2.SAXParser OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
    "jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
    it failed with the error message: "In class oracle.xml.parser.v2.SAXParser: void main(String argv[]) is not defined"
    Does anyone know how to solve the problem? I'll be appreciated very much for your help.
    Yi

    here are my ideas.
    register the xml schema.
    using xmldom, generate the desired xml output and return as xmltype.
    then you can use something like this to check.
    declare
    xmldoc xmltype ;
    begin
       -- populate xmldoc from you xmldom function
       -- validate against XML schema
       xmldoc.isSchemaValid(schema_url, root_element);
       if xmldoc.isSchemaValid = 1 then
            --valid schema
       else
            --invalid
       end if;
    end

  • Creating a command line program reading AEP/AEPX files?

    I'm new with After Effects SDK, and I wanted to know if it's possible to use SDK to implement a command line program that gets information such as duration and frame rate in AEP/AEPX files.
    aerender, a command line render program provided by After Effects, prints out these information before rendering. But it doesn't seem to be able to print out the information without doing rendering.
    I saw a related thread here: http://forums.adobe.com/thread/844341
    But what I want is simpler. I don't need to alter the AEP/AEPX files. I just want to obtain the information quickly from an AEP/AEPX file. Is it possible to write such a tool using SDK?
    Thanks!

    hi eliang.cs!
    yes, i'm the same guy who answered on the other thread.
    everything the API does, it does through AE as a plug-in.
    so if you have AE running (even just the renderer), your project loaded and your plug-in present, you can access all the data you described with no problem, and export it out in whatever way you want. (a plug-in is actually a DLL, so you can do anything you want, even on an OS level)
    you can access the data on all elements of the project including comps, layers, footage, render queue, ect...
    having said that, you can do all of this using a script instead of a plug-in.
    scripts are much easier to build.
    perhaps there's even a script out there that does what you're looking for, or something very close that could easily be adjusted.

  • How do you put a command line in adobe illustrator?

    how do you put a command line in adobe illustrator?

    Your question makes no sense. What exactly are you trying to do?

  • How can I use srvctl command line for change "Failover type" and "F method"

    Hi all,
    I am using Oracle One Node (11.2.0.3), and I have a service:
    /u01/11.2.0/grid/bin/srvctl config service -d orcl
    Service name: orcldb
    Service is enabled
    Server pool: orcl
    Cardinality: 1
    Disconnect: false
    Service role: PRIMARY
    Management policy: AUTOMATIC
    DTP transaction: false
    AQ HA notifications: false
    Failover type: NONE
    Failover method: NONE
    TAF failover retries: 0
    TAF failover delay: 0
    Connection Load Balancing Goal: LONG
    Runtime Load Balancing Goal: NONE
    TAF policy specification: BASIC
    Edition:
    Preferred instances: orcl_1
    Available instances:
    I would like to change "Failover type" and "Failover method" to:
    Failover type: SELECT
    Failover method: BASIC
    How can I do that? Is there any graphical tool for it? Or, How can I use srvctl command line for change it?
    Thanks in advance.
    Leonardo.

    user10674190 wrote:
    Hi all,
    I am using Oracle One Node (11.2.0.3), and I have a service:
    /u01/11.2.0/grid/bin/srvctl config service -d orcl
    Service name: orcldb
    Service is enabled
    Server pool: orcl
    Cardinality: 1
    Disconnect: false
    Service role: PRIMARY
    Management policy: AUTOMATIC
    DTP transaction: false
    AQ HA notifications: false
    Failover type: NONE
    Failover method: NONE
    TAF failover retries: 0
    TAF failover delay: 0
    Connection Load Balancing Goal: LONG
    Runtime Load Balancing Goal: NONE
    TAF policy specification: BASIC
    Edition:
    Preferred instances: orcl_1
    Available instances:
    I would like to change "Failover type" and "Failover method" to:
    Failover type: SELECT
    Failover method: BASIC
    How can I do that? Is there any graphical tool for it? Or, How can I use srvctl command line for change it?
    Thanks in advance.
    Leonardo.srvctl modify service -d database_name -s orcldb -q TRUE -m BASIC -P BASIC -e SELECT -z 180 -w 5 -j LONG
    Also see
    11gR2(11.2) RAC TAF Configuration for Admin and Policy Managed Databases [ID 1312749.1]

  • How can I deploy by command line on AS 10.1.3?

    I have used oracle AS 10.1.3.
    I have created ear file from command line.
    But I don't know how i can deploy by command line?
    However i can deploy from Web manage.
    So, Please tell me How i can deploy by command line when i want?
    Thx

    Hello,
    In OracleAS 10g R3 (10.1.3.x) you can deploy by command line using the admin_client.jar utility, that is exposed also as Apache Ant tasks. In 10.1.3.x you can use the same tool to deploy in a single stand alone OC4J instance to a multi-nodees cluster managed by OPMN.
    Here the documentation about this utility:
    - Deployment Guide
    - Deploying with the admin_client.jar Utility
    -Deploying with the OC4J Ant Tasks
    Regards
    Tugdual Grall

  • Is there a command line program that converts WAV to SWF?

    Is there a command line program that converts WAV to SWF?
    thanks

    why you want to do that? you can import your wav into the
    swf!

  • Cope: a command-line program colouriser

    cope is a wrapper around various command-line programs that takes their output and adds colours - a sort of ornamental cope, if you will.
    It's written in Perl, and requires version >= 5.10, so installation may be a bit complicated if you have to track down the dependencies. It installs several scripts in a directory, each one calling the program it's named after, only highlighting its output using regexes. Then you add this directory to your $PATH, and everything should (hopefully!) be seamless.
    Currently it's in release candidate status - I've been using it personally for a few weeks and nothing catastrophic has happened so far, so there's little point me keeping it private.
    Screenshots:
    Main site: http://stuff.cytzol.org/cope/
    GitHub: http://github.com/cytzol/cope

    PKGBUILD
    # Contributor: denton <e9203.00 gmail com>
    pkgname=cope-git
    pkgver=20091208
    pkgrel=1
    pkgdesc='A colourful wrapper for terminal programs'
    arch=(any)
    url=http://stuff.cytzol.org/cope/
    license=('GPL' 'PerlArtistic')
    depends=("perl>=5.10")
    makedepends=(git)
    provides=(cope)
    conflicts=(cope)
    install=$pkgname.install
    _gitroot=git://github.com/cytzol/cope.git
    _gitname=cope
    build() {
    cd $srcdir
    # Git
    msg 'Connecting to Git server...'
    if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin || return 1
    msg 'The local files are updated.'
    else
    git clone $_gitroot || return 1
    fi
    msg 'Git checkout done or server timeout.'
    msg 'Starting make...'
    rm -rf $srcdir/$_gitname-build
    git clone $srcdir/$_gitname $srcdir/$_gitname-build || return 1
    cd $srcdir/$_gitname-build
    # Build
    PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
    make || return 1
    make install DESTDIR=$pkgdir || return 1
    # Remove perllocal.pod and .packlist
    find $pkgdir -name perllocal.pod -delete
    find $pkgdir -name .packlist -delete
    cope-git.install
    post_install() {
    echo 'Prepend /usr/share/perl5/vendor_perl/auto/share/dist/Cope/ to $PATH'
    post_upgrade() {
    post_install
    First time making a perl package. It puts files that shouldn't be in */site:
    /usr/bin/perlbin/site/envpath
    /usr/lib/perl5/site_perl/5.10.1/IO/Pty.pm
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty.pm
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty/
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty/Constant.pm
    /usr/lib/perl5/site_perl/5.10.1/List/MoreUtils.pm
    /usr/lib/perl5/site_perl/5.10.1/Params/Util.pm
    /usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.so
    /usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.so
    /usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.so
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector.pm
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector/
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector/Functions.pm
    /usr/share/perl5/site_perl/5.10.1/Env/Path.pm
    /usr/share/perl5/site_perl/5.10.1/IO/Stty.pm
    /usr/share/perl5/site_perl/5.10.1/IO/stty.pl
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/CC.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/SEN.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1035.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1738.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1808.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2384.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2396.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2806.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/fax.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/file.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/ftp.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/gopher.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/http.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/news.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/pop.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/prospero.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tel.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/telnet.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tv.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/wais.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/_support.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/balanced.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/comment.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/delimited.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/lingua.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/list.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/net.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/number.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/profanity.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/whitespace.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/zip.pm
    And as shown by the previous list, I haven't fetched these binaries (are they in the repos?):
    Env::Path
    File::ShareDir
    IO::Handle
    IO::Pty
    IO::Stty
    List::MoreUtils
    Regexp::Common
    Term::ANSIColor
    Everything works, except cope_path.pl.
    Last edited by denton (2009-12-08 09:14:37)

  • Fast command-line program which displays connectivity

    Hi
    I'm looking for a command-line program which can show whether or not my network interface has an IP address or not. It could use "ifconfig" to extract the information, I don't really care, but it has to be *fast* and it cannot require root access.
    Thanks

    Thanks, but if someone knows some sed/awk magic to get only the interface's IP address, that would be great!
    EDIT:
    Using the little "sed" I know, this is what I came up with:
    ifconfig wlan0 | grep -w inet | sed "s/^\\s*//" | sed "s/^inet addr://" | sed "s/\\s.*//"
    EDIT2:
    Now I have this reasonable command:
    ifconfig wlan0 | grep -w inet | sed "s/.*inet addr:\([^ ]*\).*.*/\1/"
    Last edited by skorpan (2009-06-07 16:44:19)

  • Tagging command line programs in subtle?

    I'd like to be able to tag command line programs so I can assign them to specific views and gravities within those views.
    For example, I'd like to be able to have 'gclacli calm' be recognized by a tag so it appears in my 'agenda' view and assign it a gravity. Is there a way to do this? Right now the best I can do is limit xterm to different views but they still move around when I change  views.
    Last edited by tinySpark (2012-06-14 18:04:12)

    None of these options have worked.
    for the user variables, i just create a new one called "Path" and type in my path to java \bin right?
    This is quite frustrating. Thanks for the help though!
    --Brenton                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Setting column width in a command-line program

    Is there a way to send data to the screen in a command-line Java program that will be formatted as a number
    of columns with a set column width? I am looking for something similar to the C++ setw() I/O manipulator
    used in cout.
    Thanks,
    Steve

    If you go to: http://java.sun.com/docs/books/tutorial/essential/io/writingFiltered.html
    it will show you how to subclass a filtered output stream and add your own formatting methods.Then you can chain your new class to System.out
    like this:
    YourFilteredStream yfs = new YourFilteredStream(System.out); .
    Then:
    yfs.yourNewMethod(); goes directly to system out in the new format.

  • Command line program: can it implement keyListener??

    Hello,
    before I take the trouble to learn keyListener implementation, I am wondering if my program could even implement it. It is just a small game that just plays in the command window. I would like it to respond to the user pressing up, down, left and right keys. Is this possible with a keyListener or is this only possible in a 'windowed' application?
    And if you cannot register keys this way from the command line, then how would I make my program interactive. Do you know a link to an API description that explains how to set the program up to give a prompt?
    Thank you very much!
    -Mike.

    guess not...

  • [RESOLVED] How I pass in my command-line variables disgusts me

    Hello,
    What I'm trying to do is to make an easily configurable script that the user can run with just a few basic command line variables (some of our users are not programmers.)  Now, here's my problem, when it comes to extracting the variables from the command line, it's kind of messy.  Lets say I have the following command:
    $ ./hl_script.sh --config-file=config_abc.txt --rate=5000 --data-dump=/opt/dump_area -v
    "-v" means verbose
    Now, given the weird arrangement of the different types of command line arguments, I'd like to extract the salient parts of the information that I care about.  However, at this moment, all I have is the "cut" command which can easily get into undefined behavior territory should the user misstype an input.  I would love to know how you have done this and what your approach to this problem is.
    This is the code that I have so far:
    # this is where we run the initial test and check if the user entered the
    # help flag in order to see how to properly use this application.
    if [ $# -gt 1 ]; then
    for argument in $@
    do
    if [ $argument = "--help" ]; then
    echo "Here is how you would use this software and the flags that would"
    echo " be useful."
    echo " --help"
    echo " Brings up this display and shows a listing of the options"
    echo " that can be used to better utilize this app."
    echo ""
    echo " --config-file=N"
    echo " Specify the config file that we'd like to use."
    echo ""
    exit 0
    elif [ `cut $argument | cut -d'=' -f 1` = "--config-file" ]; then
    # read-in the config file that we specified and then proceed to set a
    # bunch of environment variables that we need.
    echo "stuff..."
    fi
    done
    fi
    Last edited by publicus (2014-05-13 13:13:43)

    ewaller wrote:
    I know your sample code is Bash, but you may want to consider doing it in Python and using this library
    Here is a simple Python program I wrote that uses the library:
    ewaller$@$odin ~/devel/python 1004 %./sieve.py
    Usage: sieve.py [options] arg
    sieve.py: error: incorrect number of arguments
    ewaller$@$odin ~/devel/python [2]1005 %./sieve.py 10
    2 3 5 7
    ewaller$@$odin ~/devel/python 1006 %./sieve.py --help
    Usage: sieve.py [options] arg
    Find prime numbers using a sieve of Eratosthenes
    Options:
    -h, --help show this help message and exit
    -v, --verbose
    ewaller$@$odin ~/devel/python 1007 %./sieve.py 10 -v
    removing 4
    removing 6
    removing 8
    removing 10
    removing 6
    removing 9
    removing 10
    2 3 5 7
    ewaller$@$odin ~/devel/python 1008 %cat sieve.py
    #! /usr/bin/python
    Implement a sieve of Eratosthenes
    from optparse import OptionParser
    def main():
    #Handle all the command line nonsense. We need a number as an argument
    usage = "%prog [options] arg"
    description = "Find prime numbers using a sieve of Eratosthenes"
    parser = OptionParser(usage=usage,description=description)
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose")
    (options, args) = parser.parse_args()
    if len(args) != 1:
    parser.error("incorrect number of arguments")
    try:
    maxval=eval(args[0])
    except:
    parser.error ("Argument is not a number")
    # Here is the sieve
    a=[x for x in range(0,maxval+1)]
    for count in range(2,int(maxval/2)+1):
    if a[count]:
    for i in range(count*2,maxval+1,count):
    a[i]=0
    if options.verbose:
    print ("removing %i"%i)
    # and report the results
    wrap=0
    for count in range(2,len(a)):
    if a[count]:
    print (count,end=" ")
    wrap += 1
    if (wrap == 5):
    print()
    wrap = 0
    print ()
    if __name__ == "__main__":
    main()
    ewaller$@$odin ~/devel/python 1009 %
    The thing is, I already have some shell code written that works, so I don't want to re-write (and re-test) that.

Maybe you are looking for

  • Printing from a Stored Procedure on HP-UX

    We've created a Stored Procedure on Our Oracle 8 Database and we need to print an order form to a remote print on a Windows Network. How can I do this.

  • Can one import photos from an iPod to a MacBook Air?  How?

    I've lost a number of photos, and they now are only on a second generation iPod.  I want to see if I can retrieve them from there as opposed to replacing them with what is now on the MacBook Air.  Any assistance at all would be GREATLY appreciated!!

  • SUS - MM Scenario: notification mail not sent to all Supplier Users

    Hi, we're in a SUS-MM scenario and we publish Purchasing documents (PO and/or SAR) to SUS portal. The notification mail for new published documents are sent only to the e-mail address of the Supplier (imported from SAP to SUS) which is in the SAP Sup

  • Table cannot be outer joined

    hi i have this query SELECT xoj.entry_date job_date, xoj.well, xoj.rig, xoj.job_type,        xoj.job || xoj.job_type job_descritpion, xoj.opn_job_desc,        lab2.well_depth, fvl.attribute1, xoj.contract, xoj.invoice_date,        xoj.invoice_ref,   

  • How to make items in a region populate a parameter in another region

    I have two regions in an APEX page: List of items (hyperlinks) on the left, PL/SQl block containing a media player for videos on the right. What I want is for the list to talk to the media player. Click an item in the list and that populates what fil