#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
void isphone(int number)
{
bool isphone = false;
int size2= number.size();
for (int i=0; i<size2; i++)
{
if(isdigit(number[i])&& size2>=4)
{
isphone=true;
}
else
isphone = false;
if(isphone=true)
{
cout<<"yes this is a phone number"<<endl;
}
else
cout<<"Invalid number!"<<endl;
}
}
//for testing purpose
int main(int argc, char* argv[])
{
if (argc==2)
isphone(string(argv[1]));
}
I was thinking to use this function to read the user input to see if they input the right number. But it just wont allow me to run! It has something like
testing.cpp: In function 'void isphone(int)':
testing.cpp:11: error: request for member 'size' in 'number', which is of non-class type 'int'
testing.cpp:14: error: invalid types 'int[int]' for array subscript
testing.cpp:22: warning: suggest parentheses around assignment used as truth value
testing.cpp: In function 'int main(int, char**)':
testing.cpp:38: error: 'isname' was not declared in this scope
Compilation failed.
O.O can someone plz help me figuring it out? I see no problem....or any suggestion to modify it?