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

RE: [LCP]Very Small Doubt...



You should initialeise the char pointers to address some memory somewhere
for the scanned strings to be stored...

On Monday, July 08, 2002 11:58 PM, Goverthanan [SMTP:verthan@miel.mot.com]
wrote:
> 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