#include<stdio.h>

main()

{

struct xx

{

int x=3;

char name[]="hello";

};

struct xx *s;

printf("%d",s->x);

printf("%s",s->name);

}

Answers were Sorted based on User's Feedback



#include<stdio.h> main() { struct xx { int x=3; ..

Answer / susie

Answer :

Compiler Error

Explanation:

You should not initialize variables in declaration

Is This Answer Correct ?    10 Yes 3 No

#include<stdio.h> main() { struct xx { int x=3; ..

Answer / anand

Compilation error
you should not iniialize the structure variable inside the
declaration.

Is This Answer Correct ?    4 Yes 2 No

#include<stdio.h> main() { struct xx { int x=3; ..

Answer / rahulkulkarni

There is no syntax error.

Pointer s is declared but never initialized.

Using uninitialized pointer , trying to access members(x and name) of structure results in invalid access of memory.

Hence segmentation fault.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

write a program in c to merge two array

2 Answers  


Design an implement of the inputs functions for event mode

0 Answers   Wipro,


#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }

1 Answers  


main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }

1 Answers  


main() { int i=5; printf("%d",++i++); }

1 Answers  






Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }

2 Answers  


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,


main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

3 Answers  


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

0 Answers  


main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

1 Answers  


Categories