Thread: dos prompt disappearing

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by major_small
    follow the standards and we can help you better... you need the <cstring> header for strcmpi, or in the older standards, <string.h>...
    Well using the standard and strcmpi don't go together as the function is non standard.

    Again I'll refer you to my posting using std::string instead of a character array. It won't do insenstive comparison but with a little work it can.

    Edit: Just noticed one small mistake on the code in the std::string post but I can't edit that post.
    Code:
    system(command);
    Should be
    Code:
     system(command.c_str());
    My apologies for that mistake


    However if you are dead set on using a null terminated array of characters here is some advise:

    Using a loop to keep things alive while the person is executing commands. If you wish to use functions to get the input use return values to determine if you should continue or not.

    As to why your program fails:
    Code:
    #include <iostream.h>
    New standard specifies that the header should be <iostream>
    Code:
    char command[99999];
    Not invalid just not good practice to use global variables

    Code:
    void exec();
    void call();
    These are ok and act as a prototype for the functions
    Code:
    int main()
    {
    Still ok
    Code:
        void exec();
    And here we have a problem. You think this is a call but guess what? It isn't. Its acting as a prototype for exec. to make it a call just use exec();
    Code:
    }
    
    void exec()
    {
        cout << "Command>";
        cin.getline(command, 99999, '\n');
    This is ok
    Code:
        if(command = "quit")
    Here you are trying to assign the const array of characters "quit" to the array command which isn't valid
    Code:
        {
            return;
        }
        
        else
        {
    This is ok
    Code:
            void call();
    Same as above, its a prototype not a call
    Code:
        }
        
    }
    
    void call()
    {
        system(command);
    This is ok
    Code:
        void exec();
    Again a prototype not a call
    Code:
    }
    This is ok
    Last edited by Thantos; 09-02-2004 at 10:41 AM.

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by Thantos
    Well using the standard and strcmpi don't go together as the function is non standard.
    good point... I was just saying that it was a depreciated header... that's all...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling from DOS Prompt using Visual Studio Express 2005
    By The SharK in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 01:24 AM
  2. Dos prompt cursor position
    By bally1020 in forum C Programming
    Replies: 2
    Last Post: 02-17-2005, 05:10 PM
  3. Output in DOS Prompt
    By siumui in forum C Programming
    Replies: 4
    Last Post: 12-06-2002, 11:27 PM
  4. DOS prompt disapearing
    By Zahl in forum Tech Board
    Replies: 6
    Last Post: 11-17-2002, 06:59 PM
  5. Dos Prompt
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 01-05-2002, 10:14 AM