0

second scanf seems to be non working and i don't get it...

printf("Please select a finishing position for a figure for instance E4\n");
		scanf("%c %d",&c1,&y0);
		printf("%c\n",c1);
				if(c1=='Q')//Exit chess
		                  {
                          printf("Thank you and goodbye\n");
                          return 0;
                          }
         else
         {

        x2=char_to_int(c1);
		 printf("%d\n",x2);
         printf("%d\n",y0);
		y2=y0-1;
         }
0

i think it might be a problem:
I started to play with int_to_char

#include<stdio.h>
  int char_to_int(char c);

  int main()
  {
  int i;
  char c,c1,c2,c3;
  printf("enter a char\n");
  scanf("%c",&c);
  i=char_to_int(c);
  printf("the number of column is:%d\n",i);
   printf("enter a char\n");
    scanf("%c",&c1);
    i=char_to_int(c1);
  printf("the number of column is:%d\n",i);
   printf("enter a char\n");
  scanf("%c",&c2);
  i=char_to_int(c2);
  printf("the number of column is:%d\n",i);
   printf("enter a char\n");
  scanf("%c",&c3);
  i=char_to_int(c3);
  printf("the number of column is:%d\n",i);
  return 0;



}


  int char_to_int(char c)
    {

        int x;
        while(c!='Q')
               {
                    if((c!='A')||(c!='B')||(c!='C')||(c!='D')||(c!='E')||(c!='F')||(c!='G')||(c!='H'))
                       {
                       x=c-'A';//A will be converted to 0, B to 1, etc...
                       return x;
                       }
                       }

}

Try to run it maybe you'll get it... Thanx

0

printf("Please select a finishing position for a figure for instance E4\n");
scanf("%c %d",&c1,&y0);
printf("%c\n",c1);

AGAIN you ended up giving a space here.

Edited by DJSAN10: n/a

0

printf("Please select a finishing position for a figure for instance E4\n");
scanf("%c %d",&c1,&y0);
printf("%c\n",c1);

Again you ended up putting a space between your format specifiers in scanf.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.