Results 1 to 12 of 12
  1. #1
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    4,922
    My Mood
    Cool

    ERROR, with my code.

    When i use AddItem[Located in sTab struct. I get an error about Char*Item_Name. It Compiles fine just when I call that one function everything got a problem.



    [php]struct sItem
    {
    char* Name, **Options;
    int* Value;
    bool Selectable;
    sItem(char* NAME, char** OPTIONS, int* VALUE, bool SELECTABLE)
    {
    Name=NAME;Options=OPTIONS;Value=VALUE;Selectable=S ELECTABLE;
    }
    ~sItem()
    {}
    };

    struct sTab
    {
    int noItems, totHeight;
    char* Name;
    sItem* Items;
    int Selected;

    void AddItem(char* Item_Name, char** Options, int* DefaultValue=0)
    {
    Items[noItems]=sItem(Item_Name, Options, DefaultValue, true);
    noItems++;
    totHeight=(noItems*15);
    }
    void AddText(char* Item_Name, char* Option)
    {
    Items[noItems]=sItem(Item_Name, (char**)Option, 0, false);
    noItems++;
    totHeight=(noItems*15);
    }

    sTab(){
    Name="New Tab";
    noItems=0;
    totHeight=60;
    Selected=0;
    }
    ~sTab()
    {
    Items=new sItem((char*)NULL,(char**)NULL, (int*)NULL, (bool)NULL);
    Name=(char*)NULL;
    noItems=0;
    totHeight=0;
    }
    };
    [/php]
    Last edited by topblast; 01-11-2011 at 12:26 AM.
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  2. #2
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,170
    Reputation
    490
    Thanks
    2,252
    Pic of the Error?

  3. #3
    ac1d_buRn's Avatar
    Join Date
    Aug 2009
    Gender
    female
    Location
    CA Source Section
    Posts
    3,406
    Reputation
    157
    Thanks
    3,991
    My Mood
    Flirty
    extactly, whats the error you get?

  4. #4
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    4,922
    My Mood
    Cool
    Image added
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  5. #5
    Gordon`'s Avatar
    Join Date
    Dec 2007
    Gender
    male
    Posts
    283
    Reputation
    24
    Thanks
    325
    Code:
    sItem* Items; 
    Items=new sItem((char*)NULL,(char**)NULL, (int*)NULL, (bool)NULL); 
    Items[noItems]=sItem(Item_Name, Options, DefaultValue, true);
    i only see you creating 1 item

    be very careful with pointers!

    Code:
    char* Name, **Options;
    int* Value;
    very dangerous thing if you do it the wrong way
    Last edited by Gordon`; 01-11-2011 at 01:55 AM.


  6. The Following User Says Thank You to Gordon` For This Useful Post:

    [MPGH]AVGN (01-11-2011)

  7. #6
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    4,922
    My Mood
    Cool
    Quote Originally Posted by Gordon` View Post
    Code:
    sItem* Items; 
    Items=new sItem((char*)NULL,(char**)NULL, (int*)NULL, (bool)NULL); 
    Items[noItems]=sItem(Item_Name, Options, DefaultValue, true);
    i only see you creating 1 item

    be very careful with pointers!

    Code:
    char* Name, **Options;
    int* Value;
    very dangerous thing if you do it the wrong way
    I am still lost
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  8. #7
    Gordon`'s Avatar
    Join Date
    Dec 2007
    Gender
    male
    Posts
    283
    Reputation
    24
    Thanks
    325


  9. The Following User Says Thank You to Gordon` For This Useful Post:

    topblast (01-12-2011)

  10. #8
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,305
    Reputation
    170
    Thanks
    2,194
    My Mood
    Flirty
    Honey its cuz when you add a new item. That item doesn't exist.

    Right there babay
    Code:
    Items[noItems]=sItem(Item_Name, (char**)Option, 0, false);
    You either need to either initialize an array of sItems
    Code:
    Items = new sItems[some number];
    or
    make Items a sItems**, meaning it will only point to new sItems, and not hold the struct in the array honey.

    I would do the first since if you do the latter its a good chance your structs will be deleted since they are declared in scope babe.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  11. #9
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    4,922
    My Mood
    Cool
    Quote Originally Posted by why06 View Post
    Honey its cuz when you add a new item. That item doesn't exist.

    Right there babay
    Code:
    Items[noItems]=sItem(Item_Name, (char**)Option, 0, false);
    You either need to either initialize an array of sItems
    Code:
    Items = new sItems[some number];
    or
    make Items a sItems**, meaning it will only point to new sItems, and not hold the struct in the array honey.

    I would do the first since if you do the latter its a good chance your structs will be deleted since they are declared in scope babe.
    I am trying both now
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  12. #10
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,305
    Reputation
    170
    Thanks
    2,194
    My Mood
    Flirty
    btw that made more sense when I was a girl.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  13. #11
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    4,922
    My Mood
    Cool
    now i am getting a similar problem with my drawtext Then when i dont drawText I get an error with Show() Function
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  14. #12
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Quote Originally Posted by topblast View Post
    now i am getting a similar problem with my drawtext Then when i dont drawText I get an error with Show() Function
    Check over any code that uses pointers, Access Violations are related to reading memory (usually from bad pointers).

    It might be that you're doing the same as before, trying to access a pointer as an array to something when you've only initialised it as a single item.