Qt problem



  • @
    #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]


  • Moderators

    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 ?



  • 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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.