Can anyone help me with this code please

This is a discussion on Can anyone help me with this code please within the C Programming forums, part of the General Programming Boards category; These are my structures and when i try to access them i get an error message that says 'structure required ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    3

    Question Can anyone help me with this code please

    These are my structures and when i try to access them i get an error message that says 'structure required on left side of . or .* in function main. I have put the code below the structures any help would be much appreciated
    typedef struct {

    char part_num[7];
    int quantity;
    } I_R_details;

    typedef struct {

    char cust_name[21];
    char cust_addr[61];
    float cust_bal;
    long credit_limit;
    } creation_details;


    typedef struct
    {
    char record_type;
    char cust_code[7];
    union
    {
    I_R_details irInfo;
    creation_details cInfo;
    } unval;
    }customer;

    ...

    if(unval.I_R_details.record_type == 'I' )

    I want to see if the first letter in the record is an I then i do some code which is ok but unsure about this line though


    many thanks

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    You're using structure member type names, not member names

    customer foo;
    if ( foo.record_type == 'I' )

    Or
    foo.unval.irInfo.quantity = 1234;

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    sent a message....fellow computeach here.

    infile is text....
    outfile can be either text or binary...

    main loop.. read file record at a time.
    this can be acheived by either by
    getting the full string upto the '\n' character
    then find the length of the string to determin the type of record
    then disect the string according to the file/record structure in your project specification.
    OR
    get first character on each line of text file...which would be record type...then get remainder of the record.

    All will become clearer at dudley.
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21