problem with structs in c

Discussion in 'General Computer Support' started by student, Dec 16, 2007.

  1. student

    student

    Joined:
    Dec 16, 2007
    Messages:
    1
    hi ,

    would u plz help me to find a solution for the problem in this code. it is in the last statement b4 return ( how can i assign to objects from the same type)
    i am trying to create another instance of the object xx[] name yy.

    any help will be highly appreciated

    #include <iostream.h>
    # include <stdio.h>
    # include <stdlib.h>
    int array[10] = {5,2,7,4,5,6,5,8,9,5};

    struct mm
    {
    int (&d)[10],f;
    int *arr;
    mm()
    : d( array )
    {
    }
    };
    struct x
    {
    mm m;
    };

    int siz,c,i;

    x xx[2],yy;

    int main()
    { for(i=0;i<2;i++)
    {
    xx.m.f=7;

    xx.m.arr = new int[siz];
    for(c=0;c<10;c++)
    {
    if(xx.m.d[c]==5)
    {xx.m.arr[siz]=xx.m.d[c];siz++;}
    else
    continue;
    }
    printf("\n---> %d\n",siz);


    for(c=0;c<10;c++)
    printf(" %d\n",xx.m.d[c]);


    }
    yy = xx[0]; // here is the problem
    printf(" **%d\n",yy.m.f);
    return 0;
    }

    i am trying to creat an other instance of the object xx[] name yy
    student, Dec 16, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Accuosti
    Replies:
    3
    Views:
    482
    Travis Evans
    Sep 27, 2004
  2. Vic

    Setup MSN Shorcut problem and IE problem

    Vic, May 11, 2004, in forum: Computer Support
    Replies:
    1
    Views:
    713
    ┬░Mike┬░
    May 11, 2004
  3. Happy@Camper.Com
    Replies:
    4
    Views:
    12,437
    Happy@Camper.Com
    Jan 18, 2005
  4. Robert11
    Replies:
    2
    Views:
    1,498
    sherlockolms
    Apr 6, 2007
  5. Fogar

    Connection problem. A virus problem?

    Fogar, Jan 24, 2006, in forum: Computer Information
    Replies:
    1
    Views:
    412
    Duane Arnold
    Jan 25, 2006
Loading...

Share This Page