Important: Please read the Qt Code of Conduct -

Qt problem

  • @

    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]

  • 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": and "second": )

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

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

Log in to reply