I'm having some troubles with this exercise that I'm working on. Basically with this function void check(char *tel, char *c)
the first value of the array must be the number 2
and the others 8 must be a number between 0 and 9
.
If the conditions are met it will print V
, otherwise it will print F
.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
void check(char *tel, char *c){
int i;
if(*tel!=2) printf("Error\n");
*c='F';
return; //I guess this return is wrong
if(*tel==2)
for(i=0;tel[i]<9;i++){
if(isdigit(tel[i]));
else{
printf("Error!\n");
*c='F';
break;
return;} //this one might be in bad use too
}
else
*c='V'; //having troubles here.. i'm not seeing a way to fix this
}
int main(){
char number[9]={2,3,4,5,6,7,4,5,3};
char car;
check(number,&car);
printf("%c \n", car);
system("pause");
}