0

I dont understand why I'm getting this error here.

#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
    string value;
    int number;
    
    
    
    cout << "Enter an integer: ";
    getline( cin, value );
    if( !isvalidInt( value ) )
        cout << "The number you entered is not a valid integer."   << endl;
    else
    {
        number = atoi( value.c_str() );
        cout << "The number you entered is " << number << endl;
        cout << "Its square root is " << sqrt( number ) << endl;
    }

    system("PAUSE");
    return EXIT_SUCCESS;
}

I'm getting this error:
`isvalidInt' undeclared (first use this function)

I can't declare it cause then I ca't use it as a function.
The purpose for the exercise is to modify the program to continually request an integer until a valid number is entered.
Where did that isvalidInt come from?

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by nottoshabi
0

>>Where did that isvalidInt come from?

You wrote the program, we didn't. You will probably have to write that function yourself because it is not standard C or C++ function.

0

I did not write the program it came out of the book. Another smart person did it. I'm just supposed to modify it.
Ancient Dragon thats what I was asking what is that I have never seen that before. How do I write that function?

0

The function might be located somewhere else in the book. If not, what do you think that function is supposed to do? It looks like it's looking at a string and asking if the user input a valid integer.

0

Yeah Rashakil Fol. I did some more searching and I found what I was looking for. Thanks for your help guys.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.