View Single Post
Old 04-16-2005, 01:11 AM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
You could make it C++ like:
Code:
 class my_struct{
  public:
    TCHAR    *FileName;
    int            Index;
    int            Frequency;
    mystruct(){ 
        Filename = NULL; 
        Index = 0;
        Frequency = 0;
     };
};

my_struct *test = new my_struct;

if (test->FileName != NULL) {
  print("Odd pointer found");
  return -1;
}
Or make it the way real C programmers do
Code:
 typedef struct {
  TCHAR         *FileName;
  int            Index;
  int            Frequency;
} my_struct;

my_struct *test = (my_struct*)malloc (sizeof(my_struct));
if(!test)
{
    perror("Not enough space on the heap\n");
    return -1;
}
memset(test, 0, sizeof(my_struct));
if (test->FileName != NULL) {
  print("Odd pointer found");
  return -1;
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote