check an phone number area code with strncmp
이전 댓글 표시
The phone number should be ###-###-####, which is including the dash. I am writing a function to determine whether a string form a phone format and a right area code checking for a three character combination followed by a dash. however, if I put dash in the string, it means to subtract. How can I avoid that?
function y = areacode(pnumber)
usernum = input('Enter your number with dash : ' )
if strncmp(pnumber,usernum,4)== 1
disp('The area code is same!')
else
disp('The area code is not same.')
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 IEC Certification Kit (for ISO 26262 and IEC 61508)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!