c question

Posted on 2007-03-26
Last Modified: 2010-04-15
what does a=(0) mean in this code.??

int main(){
    struct xyz{
           int i;
        xyz *p,a=(10);
Question by:shilpi84
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 53

Accepted Solution

Infinity08 earned 250 total points
ID: 18794598
It's not valid C.

Use this instead :

int main(){
  struct xyz {
    int i;
  struct xyz *p, a = { 10 };  /* <-- the correct way to initialize a struct is with {}'s */
                              /* <-- you have to use "struct xyz" instead of just "xyz" */
  p = &a;   /*  <-- don't assign to *p, as you haven't allocated memory for it !! */
  p->i = 10;
  printf("%d", a.i);
LVL 84

Assisted Solution

ozo earned 250 total points
ID: 18794629
assuming you meant
 struct xyz *p,a={10};
it means
struct xyz a;

refrerences an uninitialized pointer, which makes the behaviour of the program undefined

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question