Having trouble with variable types
As some of you are aware I am trying to make a program to make a code that will read 10 characters and from there display numerous outputs depending on what characters are present.
I have successful with the guidance of some of you here wrote the correct source code and it will read the characters. However I would like ir to distingguish between the first and the second character so I can display different ouputs depending on the first and second characters independantly.
my code is as follow
Code:
#include<stdio.h>
void main(void)
{
int search, c, n, count = 0, number, count1[127]={0}, count2[127]={0}, i, a;
char array[127], array1[127];
n = 10;
for ( c = 0 ; c < n ; c++ )
scanf(" %c %c ",&array[c], &array1[c]);
for(i=0;i<n;i++)
{
count1[array[i]]++; //if array[i] is N, then count1[N]++//
}
for(i=0;i<127;i++)
{
if(count1[i] == 5)
printf("Flush.\n");
if(count1[i] == 4)
printf("Four of a kind.\n");
if(count1[i] == 3)
printf("Three of a kind.\n");
if(count1[i] == 2)
printf("Pair.\n");
if(count1[i] == count1[i] && count1[i] == 2)
printf("Two Pair.\n");
for(a=0;a<n;a++)
{
count1[array1[a]]++; //if array[a] is N, then count1[N]++//
}
for(a=0;a<127;a++)
{
if(count1[a] == 5)
printf("Flush.\n");
if(count1[a] == 4)
printf("Four of a kind.\n");
if(count1[a] == 3)
printf("Three of a kind.\n");
if(count1[a] == 2)
printf("Pair.\n");
if(count1[a] == count1[a] && count1[a] == 2)
printf("Two Pair.\n");
};
return 0;
}
}
I am not sure if I have done the correct thing with making two arrays.
Just to help out anyone is trying to help me, my input would be something along the lines of
" c4 c7 sj sa h7" all representing cards from a deck of cards.
Thank you so much for your time.