- 论坛徽章:
- 0
|
1 [root@uppserver exercises]# cat char_error.c
#include<stdio.h>
int main()
{
char a,b;
printf("input a and b :");
scanf("%d,%d",&a,&b);
printf("%d,%d\n",a,b);
return 0;
}
[root@uppserver exercises]# ./char_error
input a and b :65,66
0,66
Segmentation fault (core dumped)
2[root@uppserver exercises]# cat char_error.c
#include<stdio.h>
int main()
{
char a,b,*p;
printf("input a and b :");
scanf("%d,%d",&a,&b);
p=&a;
printf("%d,%d\n",a,b);
return 0;
}
[root@uppserver exercises]# ./char_error
input a and b :65,66
0,66
3 [root@uppserver exercises]# cat char_error.c
#include<stdio.h>
int main()
{
char a,b;
printf("input a and b :");
scanf("%d,%d",&b,&a);
printf("%d,%d\n",a,b);
return 0;
}
[root@uppserver exercises]# ./char_error
input a and b :65,66
66,65
Segmentation fault (core dumped)
4 [root@uppserver exercises]# cat char_error.c
#include<stdio.h>
int main()
{
char a,b;
char *p;
printf("input a and b :");
scanf("%d,%d",&b,&a);
p=&a;
printf("%d,%d\n",a,b);
return 0;
}
[root@uppserver exercises]# ./char_error
input a and b :65,66
66,65 |
|