Thread: lists

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    57

    lists

    can anyone see why this code isnt working?

    Code:
    while(array[i][j] != '?')//while not end of array
    	//invariant: array[i][j] is not a question mark and array[i][j] is part of an array
    	{
    		StackFramePtr temp;
    		temp = new StackFrame;
            temp->data = array[i];
    		i++;
    		temp->link = top;
    		top = temp;
    	}

  2. #2
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    What kind of erros are u getting?? Compile-time or runtime??? What line???

    At a first glance this doesn´t seem to be right
    Code:
    while(array[i][j] != '?')//2D-Array
    Code:
    temp->data = array[i];//Now 1D-Array???
    Need to see more code to solve this error (and know what kind of error it is).
    Also read this before replying

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    There is a design error in your code. Array never gets updated.

    Kuphryn

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    57
    its a run time error.......i'm trying to input an array into a linked list. i dont think it has anything to do with changing it fropm a 2 to a 1 dimensiona array because it works when i just have the while loop do this......

    cout << array[i];
    i++;

    what do you mean the array never gets updated?

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    57
    if i make this linked list in a while statement, can i still access it outside the while statement?

  6. #6
    Registered User
    Join Date
    Feb 2003
    Posts
    57
    never mind.......i'm an idiot and figured it out. i had a null as the last place in the linked list and when i was tested it i was only outputting the top->data which was a null and didnt output anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help creating lists of pointers
    By The_Kingpin in forum C Programming
    Replies: 2
    Last Post: 12-11-2004, 08:10 PM
  2. Question about Linked lists of lists
    By hear_no_evil in forum C Programming
    Replies: 2
    Last Post: 11-08-2004, 02:49 AM
  3. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 04:32 PM
  4. Map file formats and linked lists
    By Spitball in forum Game Programming
    Replies: 2
    Last Post: 03-04-2004, 11:32 PM
  5. need help w/ linked lists
    By MKashlev in forum C++ Programming
    Replies: 11
    Last Post: 08-05-2002, 08:57 PM