[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[LCP]Very Small Doubt...



hi all,
this is a very small doubt in c.
On execution the following program throws segmentation fault error.

#include <stdio.h>
#include <string.h>
 
main()
{
int n;
char *str, *str1;
scanf("%s", str);
scanf("%s", str1);
scanf("%d",&n);
printf("%d\n", bcmp(str, str1, n));
}
 
Instead when the order of variable declaration is changed, program worked fine.
 
May i know what makes the diffenence in the order of variable declarations.
 
Regards,
Goverthan