struct input
{
char user[30];
char id[20];
int grades1;
int grades2;
int grades3;
int grades4;
int grades5;
int avg;
input *next;
};int j,i=1,funcavg[50];
char funcuser[50][36];
current=head;
cout << " UsernameID numberAverage
" << " ------------------------
";
do
{
strcpy(funcuser[i]," ");
strcat(funcuser[i], current->user);
funcavg[i]=current->avg;
current=current->next;
i++;
}
while(current!=NULL);
for(j=1;j<i;j++)
{cout << setw(1) << funcuser[j][36] << setw(12) << funcavg[j] << "
";}
linked lists, arrays, and bubble sorts
Page 1 of 14 Replies - 2638 Views - Last Post: 01 November 2001 - 09:19 AM
#1
linked lists, arrays, and bubble sorts
Posted 30 October 2001 - 10:13 AM
im trying to assign the info in the linked list, to an array, so that i can peform a bubble sort on the code. but the username(funcuser variable) wont print out in the do while loop. i would think this code is correct. here the functions code, and the struct declaration. thanx in advance.
Replies To: linked lists, arrays, and bubble sorts
#2
Re: linked lists, arrays, and bubble sorts
Posted 31 October 2001 - 08:36 AM
funcuser is a two dimensional array...you should have a subscript in both the strcpy and the strcat statements.
#3
Re: linked lists, arrays, and bubble sorts
Posted 31 October 2001 - 09:18 AM
yea, ive done that, and i get these errors.
--------------------Configuration: gradebook (program 4) - Win32 Debug-------------------- Compiling... gradebook (program 4).cpp D:Josh RiveraAdvanced Computer Scienceprogram 4gradebook (program 4).cpp(516) : error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast D:Josh RiveraAdvanced Computer Scienceprogram 4gradebook (program 4).cpp(517) : error C2664: 'strcat' : cannot convert parameter 1 from 'char' to 'char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe.gradebook (program 4).exe - 2 error(s), 0 warning(s)
#4
Re: linked lists, arrays, and bubble sorts
Posted 31 October 2001 - 01:21 PM
Ah yes, I forgot that part. The str functions all take dynamic character arrays as their arguments. All you need to do is put an address-of operator in front of the character array names:
strcpy(&funcuser[i], " ");
edit:took out smiley
(Edited by supersloth at 10:16 am on Nov. 1, 2001)
#5
Re: linked lists, arrays, and bubble sorts
Posted 01 November 2001 - 09:19 AM
ok, that worked without errors, but when it prints out, i get nothing from those variables, but at least im not getting those weird ass symbols....
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|