c - Integer from pointer warning -
i have problem. 2 warnings console, dont know what's wrong code. can have look? program suppose show lines @ least 11 characters , 4 numbers
#include <stdio.h> #include <ctype.h> int main() { char line[200]; printf("enter string: \n"); while(fgets(line, sizeof(line),stdin)) { int numberalpha = 0; int numberdigit = 0; if(isalpha(line)) numberalpha++; else if(isdigit(line)) numberdigit++; if(numberalpha+numberdigit>10 && numberdigit>3) printf("%s \n", line); } return 0; }
both isalpha()
, isdigit()
takes int
, not char *, argument
.
in code, passing array name argument, you're passing char *
(array name decays pointer first element when used function argument), so, you're getting warning.
you need loop on individual elements of line
, pass them functions.
that said, suggestion, hosted environment, int main()
should int main(void)
conform standard.
Comments
Post a Comment