Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt problem
Qt 6.11 is out! See what's new in the release blog

Qt problem

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 3 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shalenb
    wrote on last edited by
    #1

    @
    #include<QString>
    #include<QTextStream>

    int main(int argc, char *argv[]){
    QTextStream cout(stdout);
    bool ok;
    double length = QString(argv[1]).toDouble();
    double breadth = QString(argv[2]).toDouble();

    double area = length * breadth;

    if (area == 0.0)

    cout << "The area of length: " << length << " and breadth "
    << breadth << " is : " << area << "squared cm";
    return 0;

    }
    @

    ello my question is -
    A)Generate appropriate messages when no command line arguments are provided
    B) and the command line arguments are non-numeric values
    can someone please help with this ?
    Thank you kindly

    [edit: please use @ tags around your code, Eddy]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      welcome to devnet

      As far as I see those are hardly Qt problems.

      For A the command line check I recommend some of the standard tutotrials for C++ (e.g. "first":http://www.cprogramming.com/tutorial/lesson14.html and "second":http://www.learncpp.com/cpp-tutorial/713-command-line-arguments/ )

      For B you seem to be on a pretty good path or do you see a problem ?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        David.Waller
        wrote on last edited by
        #3

        For A), I would suggest you look at the variable argc which gives a count of the number of arguments (including the actual command)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved