I'm learning C (the hard way) and try to write a function (simple exercise) that prints a line according to argument datatype.
#include<stdio.h>
#include<ctype.h>
int main( int argc, char *argv[] )
{
int i = 0;
for(i = 0; i < argc; i++){
if(isalpha((int)argv[i]) ) //this line produces a warning
{
printf("I am alpha.\n");
}
}
return 0;
}
This produces a warning upon compilation (and does nothing upon execution):
cast to smaller integer type 'int' from 'char *' [-Wpointer-to-int-cast]
update after comments I'm comparing pears and apples: string versus int and they are not same amount of bytes. So the question is: how do I write a data comparison if-statement, like in ruby:
a = "5"
if a.instance_of? String
# do something
end