[LCP]Very Small Doubt...
Andrew Weaver
Andrew.Weaver at tecnomen.fi
Mon Jul 8 21:00:07 UTC 2002
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 at 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
More information about the linuxCprogramming
mailing list