Error when using scanf "%d" then "%s".

Правка en1, от ContestDestroyer, 2017-10-05 22:36:52

A guy gave me this code:

#include<stdio.h>
#include<conio.h>
void main(void)
{
    int b;
    char a;
    scanf("%d",&b);
    scanf("%s",&a);
    printf("%d",b);
    getch();
}

I knew that he used the wrong specifier for char a, but this code ran, and after that, b's value that i had typed before was changed to another value. I'm very curious about this case, can someone show me how this is done?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский ContestDestroyer 2017-10-05 22:36:52 471 Initial revision (published)