8 Replies - 2034 Views - Last Post: 18 October 2001 - 08:22 AM Rate Topic: -----

#1 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4517
  • View blog
  • Posts: 28,417
  • Joined: 21-March 01

linked lists

Posted 17 October 2001 - 08:09 AM

im learning linked lists, and was wondering, how i would use a multi-dimensional array using linked lists, i got my gradebook to accept student names, and id numbers, but when i try to use a m-d array im completely lost, a quick explanation would help a lot. thanx.
Is This A Good Question/Topic? 0
  • +

Replies To: linked lists

#2 nighthawk  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 1,269
  • Joined: 11-April 01

Re: linked lists

Posted 17 October 2001 - 09:08 AM

sorry sloth, can't help you this time, i'm only bearly learning about linked lists...
Was This Post Helpful? 0
  • +
  • -

#3 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: linked lists

Posted 17 October 2001 - 11:49 AM

when using linked lists you shouldn't need a multidimesional array.

But if it is absolutely necessary.... are you using a structure if so make sure that the md array is in that structure.

Ummm other than that let me think about it.

Was This Post Helpful? 0
  • +
  • -

#4 Null and Void  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 204
  • Joined: 29-April 01

Re: linked lists

Posted 17 October 2001 - 02:54 PM

Putting it in a structure/class is the easiest method. Other than that, you'd have to deal with an abnormal amount of memory allocation to do it (which isn't really bad, but is a pain to code for an assignment or something simple like that).
Was This Post Helpful? 0
  • +
  • -

#5 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4517
  • View blog
  • Posts: 28,417
  • Joined: 21-March 01

Re: linked lists

Posted 17 October 2001 - 03:39 PM

well, im just used to using m-d arrays, its what i use in most of my programs to date, im just getting some really weird errors when i try to use arrays to take in the users grades, stuff like it printing out tons of equals signs, so i was wondering bout any help, and just figured, starting from arrays(int or float types) would be the way to go. so i guess what im really wondering, is how would i take in numbers, cause im only taking in chars in my program now.
Was This Post Helpful? 0
  • +
  • -

#6 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: linked lists

Posted 17 October 2001 - 03:51 PM

I don't get it.
Was This Post Helpful? 0
  • +
  • -

#7 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4517
  • View blog
  • Posts: 28,417
  • Joined: 21-March 01

Re: linked lists

Posted 17 October 2001 - 04:08 PM

well, its in structures, and working, but im getting some cannot convert char from int to *char error, so im wondering whats up with my program, would you guys like to see some code?
Was This Post Helpful? 0
  • +
  • -

#8 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: linked lists

Posted 18 October 2001 - 12:35 AM

Yeah, that'd help :p
Was This Post Helpful? 0
  • +
  • -

#9 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4517
  • View blog
  • Posts: 28,417
  • Joined: 21-March 01

Re: linked lists

Posted 18 October 2001 - 08:22 AM

ok, this is the code, to where i enter the students name, and id number into the linked list.

void addu()
{
input *newrec;

newrec = new input;

if(newrec != NULL) { cout << "Please enter the new username"; cin.get(newrec->user,30); cin.ignore(80,' '); cout << "Please enter the new users ID number"; cin.get(newrec->id,30); cin.ignore(80,' ');

insert(newrec); } else { cout << "WARNING: Memory error. New record cannot be added. "; } }//end function

and it works fine, but when i try to enter grades, i get some weird shiznit to start happening.

heres my add grade function

void addg()
{
cout << "7h15 func710n 15n7 r3ady y3t, f00
";
//input info;
input *newrec;
newrec = new input;
char search[20];
int num,j,i;
input *previous;
previous = NULL;
current=head;

cout << " Enter the username you wish to enter grades for for: "; cin.get(search,20); cin.ignore(80, ' ');

while((strcmp(current->user,search)!=0)&&(current != NULL)) { previous=current; current=current->next; }

if(current != NULL) { cout << " RECORD FOUND "; cout << " How many grades do you wish to enter?"; cin >> num; cin.ignore(80,' '); for(i=1;i<=num;i++) { cout << "Please enter grade " << i << " "; cin.get(newrec->grades[i]); cin.ignore(80,' '); } for(j=1;j<=num;j++) { cout << "Grade " << j << " " << current->grades[j]; } } else { cout << "NO MATCH FOUND "; }

} else { cout << " NO RECORDS TO DISPLAY "; } }//end function

my struct is declared like this

struct input
{
char user[30];
char id[20];
char grades[20];
input *next;
};


and it at least compiles, but im getting all of my output as this
Enter the username you wish to enter grades for for: sloth

RECORD FOUND

How many grades do you wish to enter?3 Please enter grade 1 12 Please enter grade 2 98 Please enter grade 3 99 Grade 1 -Grade 2 -Grade 3 -Press enter to continue

those -'s(there showing up as ='s signs in my program, just not when i copy and paste) are replacing the numbers.....

and when i change the grades variable in my struct from a char to an int, i get this error.

D:Josh RiveraAdvanced Computer Scienceprogram 4gradebook (program 4).cpp(587) : error C2664: 'class istream &__thiscall istream::get(char &)' : cannot convert parameter 1 from 'int' to 'char &'
        A reference that is not to 'const' cannot be bound to a non-lvalue

ok, i hope this helps, im at skool, otherwise id put up some screen shots. thanx.

(Edited by supersloth at 10:22 am on Oct. 18, 2001)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1