Results 1 to 2 of 2

Thread: Program running error in cpp shell

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2018
    Posts
    1
    Qt products
    Qt/Embedded

    Default Program running error in cpp shell

    I got the output as

    dfgd
    Enter your string : The string is : dfgd

    for the program below. The text "Enter your string " appear below the input section rather it requires being above the input of string. Any please help

    #include<iostream>
    using namespace std;

    class activity4
    {
    private:
    string chkSt;
    public:
    void stFn(string myStr)
    {
    cout<<"The string is : "<<myStr;

    }
    };

    int main()
    {
    activity4 act;
    char str[30], ch;
    int i = 0;

    cout<<"Enter your string : ";

    while(ch != '\n')
    {
    ch = getchar();
    str[i] = ch;
    i++;
    }
    str[i] = '\0';
    act.stFn(str);
    return 0;
    }

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program running error in cpp shell

    Hi, you can try to flush cout:
    Qt Code:
    1. cout<<"Enter your string : " << std::flush;
    To copy to clipboard, switch view to plain text mode 

    Ginsengelf

Similar Threads

  1. C++ runtime Error in Running Program
    By ramin.lich in forum Newbie
    Replies: 2
    Last Post: 4th September 2014, 10:31
  2. Running shell script with as super user in N900
    By spylvas in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 30th April 2010, 02:05
  3. Program running error in qtopia 2.2.0
    By halloworld in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 15th February 2009, 10:23
  4. running shell command from C++ code problem
    By alex chpenst in forum Qt Programming
    Replies: 4
    Last Post: 31st July 2008, 11:41
  5. Replies: 1
    Last Post: 17th May 2006, 01:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.