Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,605 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 907 people online right now. Registration is fast and FREE... Join Now!




Please help me with peace of code.

 
Reply to this topicStart new topic

Please help me with peace of code., Some problems with variables

maugly
post 16 Jul, 2008 - 05:51 AM
Post #1


New D.I.C Head

*
Joined: 20 Jun, 2008
Posts: 23


My Contributions


Hi all!
I'm recieving some errors from the program about the variables defined on this info.h file.
Maby someone can see the error.
Thanx.


CODE


#ifndef _INFO_H
#define _INFO_H
int follow;
typedef struct
{
    long makat;
    char booknam[30];
    int year;
    int quantity;
    struct
    {
        float clientcost;
        float buycost;
    }price;
    char hotzaa[20];
    struct
    {
        char name1[30];
        char name2[30];
        char name3[30];
    }names;
    struct books *next;
}book;
typedef struct
{
    long makat;
    char songname[30];
    int year, downloaded;
    char availability[3];
    struct
    {
        char name1[30];
        char name2[30];
        char name3[30];
    }names;
    struct
    {
        float clientcost;
        float buycost;
    }price;
    struct music *next;
}music;
typedef struct customers
{
    int num;
    char name[40], address[80], email[40];
    long phone;
};
music *muzptr=NULL;
book *bookptr=NULL;

typedef struct
{
    int number;
    char name[30];
    long phone;
    char email[100];
    struct boks
    {
        char buydate[20];
        int amount;
        long creditcard;
        char credexpire[20];
        char deliver;
        char datedeliver;
        struct boks *nextbook;
    }*paper;
    struct mus
    {
        char downloaddate[20];
        long creditcard;
        char credexpire[20];
        char success[10];
        struct mus *nexttrack;
    }*tracks;
}customer;

#endif




This post has been edited by maugly: 16 Jul, 2008 - 05:55 AM
User is offlineProfile CardPM

Go to the top of the page

Cerolobo
post 16 Jul, 2008 - 06:00 AM
Post #2


D.I.C Regular

Group Icon
Joined: 5 Apr, 2008
Posts: 440



Thanked 31 times
My Contributions


I only glanced through the code. The only thing that stuck out to me, was this chunk

CODE
typedef struct customers
{
    int num;
    char name[40], address[80], email[40];
    long phone;
};


Here, you are attempting to typedef a struct, but you did not provide a name for the new type.

Assuming you wanted to name the typedef type customers, it would look like this

CODE
typedef struct
{
    int num;
    char name[40], address[80], email[40];
    long phone;
}customers;


Although, I would find this to be confusing since you have another typedefed type called "customer".

Hopefully that will point you in the right directory. If not, posting the errors that the compiler gave you will be very helpful to us.
User is offlineProfile CardPM

Go to the top of the page

maugly
post 16 Jul, 2008 - 06:10 AM
Post #3


New D.I.C Head

*
Joined: 20 Jun, 2008
Posts: 23


My Contributions


CODE


music *muzptr=NULL;
book *bookptr=NULL;



those pointers are the most problematic, the program it not recognizes the pointers as structs.
User is offlineProfile CardPM

Go to the top of the page

Cerolobo
post 16 Jul, 2008 - 06:14 AM
Post #4


D.I.C Regular

Group Icon
Joined: 5 Apr, 2008
Posts: 440



Thanked 31 times
My Contributions


QUOTE(maugly @ 16 Jul, 2008 - 07:10 AM) *

CODE
music *muzptr=NULL;
book *bookptr=NULL;


those pointers are the most problematic, the program it not recognizes the pointers as structs.


Actually, those are correct. Both of the structs were typedefed, so you don't need the struct keyword. In fact, it won't work if you put struct in front of it.
User is offlineProfile CardPM

Go to the top of the page

polymath
post 16 Jul, 2008 - 08:01 AM
Post #5


D.I.C Regular

Group Icon
Joined: 4 Apr, 2008
Posts: 407



Thanked 4 times

Dream Kudos: 500
My Contributions


Actually, i thought that in C (not C++) you need the strut keyword even when typedefed when you are creating pointers to struts, and in C++, you cannot use the strut keyword. In C typedef only works on struts for non-pointing instantations.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 02:27AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month