C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-29-2007, 08:30 PM   #1
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
Looking for a way to store listbox data

This question is referring to a program I am writing for Windows, but the code I am asking for can be ANSI C.

I have a listbox containing a list of frames in an animation. I want to store some data associating with each frame. The data I want to store is: Frame Number, Frame Delay, X Offset, Y Offset, Loop Count, File Path, File Name

Now I wrote some code that uses a typedef struct to store the data, then I created a new array of them like this:
Code:
typedef struct animationstructure
{
	char filename[MAX_PATH];
	char filepath[MAX_PATH];
	int delay;
	int xpos;
	int ypos;
	int framenum;
    	int loop;
} imagestruct;

imagestruct imagedata[500];
I then proceeded to read/write from these and using the List Item Number as the index for the imagestruct.

The problem I had with this method is that when I delete an item from my ListBox, I now have a gap in my data structure which gives me issues later on down the line in my program. This is not too much of a problem unless enough frames get deleted/added enough and it will eventually cause issues with the program. Now I tried to write code to make this work by using a 2nd struct, and running through a loop and copying data from one to the other then back again without the deleted item in the struct array. The code didn't really work well at all.

So I was hoping somebody could help me out with a method of doing this. I have tried making hidden listboxes, but now I am having the program crashing and for some reason it isn't working properly. On top of that I feel it is an easy way out and I don't feel comfortable storing data in hidden controls. I would rather do it the right way. On top of that it can be optimized if I write the code myself, but not if I use Win32 API calls that do a bunch of drawing and other stuff like that.



Pardon my programming lingo. I was a software engineer for Mac OS and embedded systems up until 2002 and I have taken a career change as a Shipyard Welder. But I am now digging back into the realm of computer programming on Windows and I am hooked all over again.

So anyways, I appreciate any help you guys can give. And understand that my memory is very foggy on programming, so too much technical talk may lose me so try to dumb it down if you don't mind. Examples or actual code will really help.

Thanks.
-Nick

Last edited by Welder; 10-29-2007 at 08:33 PM.
Welder is offline   Reply With Quote
Old 10-30-2007, 12:58 AM   #2
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
Well if you have a variable called say
numEntries
and you wish to delete entry
d

Then it's just move everything down one place
Code:
for ( i = d ; i < numEntries ; i++ ) {
  imagedata[i] = imagedata[i+1];
}
numEntries--;
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Old 10-30-2007, 11:12 AM   #3
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
Thank you Salem, I will try that today and let you know how it works out.

What is the best way to change the strings held in filename/filepath?

[edit] Do you think creating some linked list functions would be a good idea on an animation program like I am creating? There will be a lot of animation frame manipulation going on in several parts of the program including dragging/dropping frames in the listbox, group editing of frame data, inserting into the middle of listbox as well as appending to the end and such so I was debating on going this route. I found a nice tutorial on using linked lists but it only explains the basics which was still VERY helpful but it doesn't have any info other than appending to the end of a heap.

Here is the tutorial I found http://cslibrary.stanford.edu/103/LinkedListBasics.pdf
I also downloaded a zip file called "Snippets" which contains some nice Linked List code but it seems more complicated than I need, and I really want to learn how to do it on my own. Not to say I won't use other people's public domain code examples but I sort of need something simple so that I can learn from it and be able to write the code on my own later on down the line. I haven't written a line of code in several years, so I am rusty to say the least.

Last edited by Welder; 10-30-2007 at 11:21 AM.
Welder is offline   Reply With Quote
Old 10-30-2007, 11:37 AM   #4
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
A linked list would be good since it simplifies the insert / removal from the middle of the list.

> char filename[MAX_PATH];
> char filepath[MAX_PATH];
In normal use, how many different files would you be pulling data from?
This represents an awful lot of duplicated data.

Consider a separate list/array of active filenames, and simply store the index in your image structure.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Old 10-30-2007, 02:32 PM   #5
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
Alright, well with a bunch of help from that tutorial, I wrote some code that does what I need.

This example only stores a single numeric variable and one pointer to the next structure. When I implement it in my application I will add the other frame properties and edit the code accordingly.

I am posting this so other people can learn from it.

Once again, most of this code was copied from http://cslibrary.stanford.edu/103/LinkedListBasics.pdf so I can't take credit for all of it, but a few of the functions I added such as deleting/inserting items from the middle.

Code:
/*

- Much of this code is from a nice tutorial I found on the internet.
- This tutorial can be found here:  http://cslibrary.stanford.edu/103/LinkedListBasics.pdf
- Several functions such as RetrieveList, DeleteItem, and InsertItem were written by me since
- the tutorial did not contain these functions which were what I needed in a program
- I am writing.
-
-
- Cheers, Nick - nvellios03@yahoo.com

*/

#include <stdio.h>
#include <stdlib.h>

struct node {
    int             data;
    struct node*    next;
};

//Linked List Functions
int ListLength(struct node* head);
void PushLinkedList(struct node** headRef, int data);
void ChangeToNull(struct node** headRef);
struct node* AppendNode(struct node** headRef, int num);
struct node* CopyList(struct node* head);
struct node* DeleteItem(struct node* head, int num);
void InsertItem(struct node** q, int loc, int num);
struct node* RetrieveList(struct node** head, int num);
//Test Functions
struct node* BuildTestList();
void LinkedListTest();

int main(int argc, char *argv[])
{
  LinkedListTest();
  system("PAUSE");	
  return 0;
}

//Test Function
void LinkedListTest()
{
    struct node* head = BuildTestList();
    struct node* newNode;
    struct node* current;
    int i=1;

    newNode = malloc(sizeof(struct node));
    newNode->data = 1;

    newNode->next = head;

    head = newNode;

    int len = ListLength(head);
    current = head;

    while(current != NULL)
    {
        printf("Item %d: %d\n", i++, current->data);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", len);

// Push Test

    printf("Push Test...\n");
    PushLinkedList(&head, 1);
    PushLinkedList(&head, 13);

    current = head;
    len = ListLength(head);
    i=1;

    while(current != NULL)
    {
        printf("Item %d: %d\n", i++, current->data);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", len);

// Add to end test

    printf("Add To End Test...\n");

    AppendNode(&head, 27);
    AppendNode(&head, 28);

    current = head;
    i=1;

    while(current != NULL)
    {
        printf("Item %d: %d\n", i++, current->data);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", ListLength(head));

// Delete Item Test

    printf("Delete Item Test...\n");
    head=DeleteItem(head, 6);
    current = head;
    i=1;

    while(current != NULL)
    {
        printf("Item %d: %d\n", i++, current->data);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", ListLength(head));

// Insert Item Test

    printf("Insert Item Test...\n");
    InsertItem(&head, 6, 120);
    current = head;
    i=1;

    while(current != NULL)
    {
        printf("Item %d: %d\n", i++, current->data);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", ListLength(head));
}

//Test Function
struct node* BuildTestList()
{
    struct node* head = NULL;
    struct node* second = NULL;
    struct node* third = NULL;

    head = malloc(sizeof(struct node));
    second = malloc(sizeof(struct node));
    third = malloc(sizeof(struct node));

    head->data = 1;
    head->next = second;

    second->data = 2;
    second->next = third;

    third->data = 3;
    third->next = NULL;

    return head;
}

//Linked List Code
void ChangeToNull(struct node** headRef)
{
    *headRef = NULL;
}

//Linked List Code
int ListLength(struct node* head)
{
    struct node* current = head;
    int count = 0;

    while(current != NULL)
    {
        count++;
        current = current->next;
    }

    return count;
}

//Linked List Code
struct node* DeleteItem(struct node* head, int num)
{
    struct node* current = head;
    struct node* newList = NULL;
    struct node* tail = NULL;
    int count=1;

    while(current != NULL)
    {
        if(count != num)
        {
            if(newList == NULL)
            {
                newList = malloc(sizeof(struct node));
                newList->data = current->data;
                newList->next = NULL;
                tail = newList;
            }
            else
            {
                tail->next = malloc(sizeof(struct node));
                tail = tail->next;
                tail->data = current->data;
                tail->next = NULL;
            }
        }

        count++;
        current = current->next;
    }

    return newList;
}

//Linked List Code
void InsertItem(struct node** q, int loc, int num)
{
    struct node *temp,*n;
    int c=1,flag=0;

    temp=*q;

    if(*q != NULL)
    {
        while(temp != NULL)
        {
            if(c == loc)
            {
                n = (struct node *)malloc(sizeof(struct node));

                n->data=num;
                n->next=temp->next;
                temp->next=n;
                flag=1;
            }
            
            c++;
            temp=temp->next;
        }
    }
}

//Linked List Code
void PushLinkedList(struct node** headRef, int data)
{
    struct node* newNode = malloc(sizeof(struct node));

    newNode->data = data;
    newNode->next = *headRef;
    *headRef = newNode;
}

//Linked List Code
struct node* AppendNode(struct node** headRef, int num)
{
    struct node* current = *headRef;

    if(current == NULL)
    {
        PushLinkedList(headRef, num);
    }    
    else
    {
        while(current->next !=NULL)
        {
            current = current->next;
        }

        PushLinkedList(&(current->next), num);
    }
}

//Linked List Code
struct node* CopyList(struct node* head)
{
    struct node* current = head;
    struct node* newList = NULL;
    struct node* tail = NULL;

    while (current != NULL)
    {
        if (newList == NULL)
        {
            PushLinkedList(&newList, current->data);
            tail = newList;
        }
        else
        {
            PushLinkedList(&(tail->next), current->data);
            tail = tail->next;
        }

        current = current->next;
    }

    return(newList);
}

//Linked List Code

struct node* RetrieveList(struct node** head, int num)
{
    struct node* current = *head;
    int counter=0;

    if(current != NULL)
    {
        while(counter != num && current->next != NULL)
        {
            current = current->next;
        }
    }

    return current;
}
Welder is offline   Reply With Quote
Old 10-30-2007, 03:31 PM   #6
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
And here is the code with all the functions in the structure.

Let me know if you guys see anything wrong with it. It compiles and runs fine but I am not sure if I still need to free() memory even when it is allocated locally in a function.

One problem I see that I am not sure if it is a problem or not is when allocating memory to my structure. Now these structures also include filename/filepath which also are allocated memory. Since these are just pointers to another location in memory I didn't think that I would need to allocate more memory to my structure.

Am I right on this?

Should it be:

struct node *node=malloc(sizeof(struct node));

or

struct node *node=malloc(sizeof(struct node)+(MAX_PATH*2));

I am thinking it should be the first one because of the reason I gave above.

Code:
/*

- Much of this code is from a nice tutorial I found on the internet.
- This tutorial can be found here:  http://cslibrary.stanford.edu/103/LinkedListBasics.pdf
- Several functions such as RetrieveList, DeleteItem, and InsertItem were written by me since
- the tutorial did not contain these functions which were what I needed in a program
- I am writing.
-
-
- Cheers, Nick - nvellios03@yahoo.com

*/

#include <stdio.h>
#include <stdlib.h>

struct node {
    char            *filepath;
    char            *filename;
    int             delay;
    int             loop;
    int             xpos;
    int             ypos;
    struct node*    next;
};

//Linked List Functions
int ListLength(struct node* head);
void PushLinkedList(struct node** headRef, int delay, int xpos, int ypos, int loop, char *filename, char *filepath);
void ChangeToNull(struct node** headRef);
struct node* AppendNode(struct node** headRef, int delay, int xpos, int ypos, int loop, char *filename, char *filepath);
struct node* CopyList(struct node* head);
struct node* DeleteItem(struct node* head, int num);
void InsertItem(struct node** q, int loc, int delay, int xpos, int ypos, int loop, char *filename, char *filepath);
struct node* RetrieveList(struct node** head, int num);
//Test Functions
struct node* BuildTestList();
void LinkedListTest();

int main(int argc, char *argv[])
{
  LinkedListTest();
  system("PAUSE");	
  return 0;
}

//Test Function
void LinkedListTest()
{
    struct node* head = BuildTestList();
    struct node* newNode;
    struct node* current;
    int i=1;

    newNode = malloc(sizeof(struct node));
    newNode->filename=malloc(MAX_PATH);
    newNode->filepath=malloc(MAX_PATH);

    newNode->delay = 1;
    newNode->loop = 1;
    newNode->xpos = 1;
    newNode->ypos = 1;
    newNode->filename = "filename";
    newNode->filepath = "C:\\filepath";

    newNode->next = head;

    head = newNode;

    int len = ListLength(head);
    current = head;

    while(current != NULL)
    {
        printf("Item %d: Delay %d, Loop %d, XPOS %d, YPOS %d, Filename %s, Filepath %s\n",
                i++, current->delay, current->loop, current->xpos, current->ypos, current->filename, current->filepath);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", len);

// Push Test

    printf("Push Test...\n");
    PushLinkedList(&head, 1, 0, 0, 0, "filename1", "C:\\filepath1");
    PushLinkedList(&head, 13, 1, 2, 3, "filename2", "C:\\filepath2");

    current = head;
    len = ListLength(head);
    i=1;

    while(current != NULL)
    {
        printf("Item %d: Delay %d, Loop %d, XPOS %d, YPOS %d, Filename %s, Filepath %s\n",
                i++, current->delay, current->loop, current->xpos, current->ypos, current->filename, current->filepath);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", len);

// Add to end test

    printf("Add To End Test...\n");

    AppendNode(&head, 27, 3, 2, 1, "filename3", "C:\\filepath3");
    AppendNode(&head, 28, 5, 8, 9, "filename4", "C:\\filepath4");

    current = head;
    i=1;

    while(current != NULL)
    {
        printf("Item %d: Delay %d, Loop %d, XPOS %d, YPOS %d, Filename %s, Filepath %s\n",
                i++, current->delay, current->loop, current->xpos, current->ypos, current->filename, current->filepath);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", ListLength(head));

// Delete Item Test

    printf("Delete Item Test...\n");
    head=DeleteItem(head, 6);
    current = head;
    i=1;

    while(current != NULL)
    {
        printf("Item %d: Delay %d, Loop %d, XPOS %d, YPOS %d, Filename %s, Filepath %s\n",
                i++, current->delay, current->loop, current->xpos, current->ypos, current->filename, current->filepath);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", ListLength(head));

// Insert Item Test

    printf("Insert Item Test...\n");
    InsertItem(&head, 6, 120, 50, 80, 90, "filename5", "C:\\filepath5");
    current = head;
    i=1;

    while(current != NULL)
    {
        printf("Item %d: Delay %d, Loop %d, XPOS %d, YPOS %d, Filename %s, Filepath %s\n",
                i++, current->delay, current->loop, current->xpos, current->ypos, current->filename, current->filepath);
        current = current->next;
    }

    printf("Number of items in list is: %d\n\n", ListLength(head));
}

//Test Function
struct node* BuildTestList()
{
    struct node* head = NULL;
    struct node* second = NULL;
    struct node* third = NULL;

    head = malloc(sizeof(struct node));
    second = malloc(sizeof(struct node));
    third = malloc(sizeof(struct node));

    head->filename = malloc(MAX_PATH);
    head->filepath = malloc(MAX_PATH);
    head->delay = 1;
    head->loop = 10;
    head->xpos = 12;
    head->ypos = 21;
    strcpy(head->filename, "testname");
    strcpy(head->filepath, "C:\\testpath");
    
    head->next = second;

    second->filename = malloc(MAX_PATH);
    second->filepath = malloc(MAX_PATH);
    second->delay = 54;
    second->loop = 140;
    second->xpos = 142;
    second->ypos = 241;
    strcpy(second->filename, "testname1");
    strcpy(second->filepath, "C:\\testpath1");
    second->next = third;

    third->filename = malloc(MAX_PATH);
    third->filepath = malloc(MAX_PATH);
    third->delay = 541;
    third->loop = 1401;
    third->xpos = 1421;
    third->ypos = 2411;
    strcpy(third->filename, "testname2");
    strcpy(third->filepath, "C:\\testpath2");
    third->next = NULL;

    return head;
}

//Linked List Code
void ChangeToNull(struct node** headRef)
{
    *headRef = NULL;
}

//Linked List Code
int ListLength(struct node* head)
{
    struct node* current = head;
    int count = 0;

    while(current != NULL)
    {
        count++;
        current = current->next;
    }

    return count;
}

//Linked List Code
struct node* DeleteItem(struct node* head, int num)
{
    struct node* current = head;
    struct node* newList = NULL;
    struct node* tail = NULL;
    int count=1;

    while(current != NULL)
    {
        if(count != num)
        {
            if(newList == NULL)
            {
                newList = malloc(sizeof(struct node));
                newList->delay = current->delay;
                newList->loop = current->loop;
                newList->xpos = current->xpos;
                newList->ypos = current->ypos;
                newList->filename=current->filename;
                newList->filepath=current->filepath;
                newList->next = NULL;
                tail = newList;
            }
            else
            {
                tail->next = malloc(sizeof(struct node));
                tail = tail->next;
                tail->delay = current->delay;
                tail->loop = current->loop;
                tail->xpos = current->xpos;
                tail->ypos = current->ypos;
                tail->filename=current->filename;
                tail->filepath=current->filepath;
                tail->next = NULL;
            }
        }

        count++;
        current = current->next;
    }

    return newList;
}

//Linked List Code
void InsertItem(struct node** q, int loc, int delay, int xpos, int ypos, int loop, char *filename, char *filepath)
{
    struct node *temp,*n;
    int c=1,flag=0;

    temp=*q;

    if(*q != NULL)
    {
        while(temp != NULL)
        {
            if(c == loc)
            {
                n = (struct node *)malloc(sizeof(struct node));

                n->delay=delay;
                n->xpos=xpos;
                n->ypos=ypos;
                n->loop=loop;

                n->filename = malloc(MAX_PATH);
                n->filepath = malloc(MAX_PATH);

                strcpy(n->filename, filename);
                strcpy(n->filepath, filepath);

                n->next=temp->next;
                temp->next=n;
                flag=1;
            }
            
            c++;
            temp=temp->next;
        }
    }
}

//Linked List Code
void PushLinkedList(struct node** headRef, int delay, int xpos, int ypos, int loop, char *filename, char *filepath)
{
    struct node* newNode = malloc(sizeof(struct node));

    newNode->delay=delay;
    newNode->xpos=xpos;
    newNode->ypos=ypos;
    newNode->loop=loop;

    newNode->filename = malloc(MAX_PATH);
    newNode->filepath = malloc(MAX_PATH);

    strcpy(newNode->filename, filename);
    strcpy(newNode->filepath, filepath);

    newNode->next = *headRef;
    *headRef = newNode;
}

//Linked List Code
struct node* AppendNode(struct node** headRef, int delay, int xpos, int ypos, int loop, char *filename, char *filepath)
{
    struct node* current = *headRef;

    if(current == NULL)
    {
        PushLinkedList(headRef, delay, xpos, ypos, loop, filename, filepath);
    }    
    else
    {
        while(current->next !=NULL)
        {
            current = current->next;
        }

        PushLinkedList(&(current->next), delay, xpos, ypos, loop, filename, filepath);
    }
}

//Linked List Code
struct node* CopyList(struct node* head)
{
    struct node* current = head;
    struct node* newList = NULL;
    struct node* tail = NULL;

    while (current != NULL)
    {
        if (newList == NULL)
        {
            PushLinkedList(&newList, current->delay, current->xpos, current->ypos, current->loop, current->filename, current->filepath);
            tail = newList;
        }
        else
        {
            PushLinkedList(&(tail->next), current->delay, current->xpos, current->ypos, current->loop, current->filename, current->filepath);
            tail = tail->next;
        }

        current = current->next;
    }

    return(newList);
}

//Linked List Code

struct node* RetrieveList(struct node** head, int num)
{
    struct node* current = *head;
    int counter=0;

    if(current != NULL)
    {
        while(counter != num && current->next != NULL)
        {
            current = current->next;
        }
    }

    return current;
}

Last edited by Welder; 10-30-2007 at 03:35 PM.
Welder is offline   Reply With Quote
Old 10-30-2007, 06:05 PM   #7
train spotter
 
Join Date: Aug 2001
Location: near a computer
Posts: 3,359
Quote:
Originally Posted by Welder View Post
I have a listbox containing a list of frames in an animation. I want to store some data associating with each frame. The data I want to store is: Frame Number, Frame Delay, X Offset, Y Offset, Loop Count, File Path, File Name
Use a listview in 'REPORT' mode. You can then insert the required number of columns, each with a title.

and/or

Use the LPARAM of each item (row) in the listview to store the array index or a pointer to the array element.

Look at Listview_SetItem() and LVITEM on MSDN.

In the LVITEM struct (init to zero), set the mask to LVIF_PARAM, the item to the row and the lparam to the array index (pointer to array).
__________________
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche

"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best

"If you are going through hell....keep going."
Winston Churchill
novacain is offline   Reply With Quote
Old 10-30-2007, 09:37 PM   #8
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
novacain, the problem I have with listviews is that I cannot find any good examples in C.

I really need an example to work off of and learn from.
Welder is offline   Reply With Quote
Old 10-30-2007, 11:18 PM   #9
train spotter
 
Join Date: Aug 2001
Location: near a computer
Posts: 3,359
A search here shows some good code...

http://cboard.cprogramming.com/searc...earchid=718201
__________________
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche

"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best

"If you are going through hell....keep going."
Winston Churchill
novacain is offline   Reply With Quote
Old 10-31-2007, 01:19 AM   #10
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
You're calling malloc in way too many places. You should have just ONE function which allocates the space for a node and initialises the various fields of that node.

Likewise, just ONE function which frees the internal pointers of the node, then frees the node itself.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Old 10-31-2007, 01:41 AM   #11
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
Ok Salem, I will try that.

I found a problem with that code. It runs perfect in the console with all my tests but crashes in my actual application. I traced it down to the RetrieveList function.

Does anything look wrong to you about this?

Code:
struct framelist* RetrieveList(struct framelist** head, int num)
{
    struct framelist* current = *head;
    int counter=0;

    if(current != NULL)
    {
        while(counter != num-1)
        {
            current = current->next;
            
            counter++;
        }
    }

    return current;
}
Welder is offline   Reply With Quote
Old 10-31-2007, 03:19 AM   #12
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
If num is greater than the list length, then it will fail.

while ( current != NULL && counter != num-1 )
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Old 10-31-2007, 10:05 AM   #13
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
Salem, this is a big request, but would you be willing to look at my project and see if you can find what is wrong and why it's crashing?

I know you probably have better things to do than trace my memory leaks and bugs, but if I don't ask i'll never know, right?

If not. that's perfectly fine, I understand completely if you don't want to.

If so, or if anybody else out there would like to help (or just check out my code) then here is my project:

http://www.megafileupload.com/en/fil...ogram-zip.html

(Click the link above then wait 30 seconds and a download button will appear)

Or try this link for direct download, this one may not work. If not try the link above:

http://uploads.megafileupload.com/ge...me=program.zip
Welder is offline   Reply With Quote
Old 10-31-2007, 12:27 PM   #14
Registered User
 
Join Date: Mar 2005
Location: Mountaintop, Pa
Posts: 1,054
Your download is missing a header file, strings.h which is referenced in your linkedlists.c file. Also, an example of a listview in c can be found here.
BobS0327 is offline   Reply With Quote
Old 10-31-2007, 12:56 PM   #15
Registered User
 
Welder's Avatar
 
Join Date: Oct 2007
Location: Washington
Posts: 100
strings.h should be a standard ANSI include in your compiler's include folder.

I've used it on every OS including MacOS with CodeWarrior, Linux with GCC and Windows with Bloodshed Dev C++ so it should be in your compiler package as well.

Thanks for that ListView example BobS0327, I appreciate it.
Welder is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HUGE fps jump DavidP Game Programming 23 07-01-2004 10:36 AM
Resource ICONs gbaker Windows Programming 4 12-15-2003 07:18 AM
can't insert data into my B-Tree class structure daluu C++ Programming 0 12-05-2002 06:03 PM
Do you store store one off data arrays in a class? blood.angel C++ Programming 5 06-24-2002 12:05 PM
Can applications store data in DLL's ? kes103 C Programming 6 06-02-2002 06:55 PM


All times are GMT -6. The time now is 07:09 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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