compare pointer and integer?
hello, everyone!
i'm trying something in c.
so far i've done a program like this:
Code:
#include<string.h>
#include<stdio.h>
char search_string[100]="\0";
char *array[50];
int loop;
int main(void)
{
while(1){
printf("\n>>");
gets(search_string);
array[0]=strtok(search_string," ");
if(array[0]==NULL)
{
printf("Error.\n");
exit(0);
}
for(loop=1;loop<50;loop++)
{
array[loop]=strtok(NULL," ");
}
if (strcmp(array[0], "A")==0) {
printf("%s\n", array[0]);
if (strcmp(array[1], "B")==0)
printf("%s", array[1]);
else if (strcmp(array[1], "C")==0)
printf("%s", array[1]);
else printf("x"); }
else if (strcmp(array[0], "D")==0)
printf("%s\n", array[0]);
}
}
now, what i'm planning to do is to give the user the ability to input an integer.
i'm wondering how to do that since everytime i try to put
the compiler says that ANSI C++ forbids comparison between pointer and integer.
What shall I do to be able to get both letters and numbers from the user.
My program(so far):
>>A B
A
B
>>A C
A
C
>>D
D
My target program:
>>A B
A
B
>>A 1
A
1
>>2
2
Thanks!