Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main(void)
- {
- int needInput = 1, test=0;
- char telNum[11];
- while (needInput == 1) {
- printf("Give me a phone number ");
- scanf("%10s", telNum);
- for (size_t i = 0; i < strlen(telNum); i++)
- {
- if (telNum[i] >= '0' && telNum[i] <= '9') {
- printf("This is a number %c\n", telNum[i]);
- test ++;
- }
- else
- {
- printf("This is not a number %c\n", telNum[i]);
- }
- }
- // (String Length Function: validate entry of 10 characters)
- if (test == 10) {
- printf("Yep, thats a phone number \n");
- needInput = 0;
- }
- else {
- printf("Enter a 10-digit phone number: \n");
- test = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement