Procedure is as follows when 0 1 2 3 4 5 6 7 8 9 run out as a result of the - 858993460 - I checked the is out of memory but why
#include
#include
# define Maxsize 100
using namespace std;
Typedef struct
{
The int data [Maxsize];
Int length;
} Sqlist;
Int Initlist (Sqlist L)
{
L.l ength=0;
return 1;
}
Int Creatlist (Sqlist L)
{
int i;
cout<" Please input: "& lt; for(i=0; i<10; I++)
{
Cin> L.d ata [I];
L.l ength++;
}
return 1;
}
Int Getelem (Sqlist L, int, int & amp; E)
{
E=L.d ata [I - 1);
return 1;
}
Int main ()
{Sqlist s;
Int p=100;
Initlist (s);
Creatlist (s);
Getelem (s, 2, p);
coutsystem("pause");
}
CodePudding user response:
Brother, you this value transfer calls, of course not ok.
The reference or pointer, CodePudding user response:
Int Initlist (Sqlist L)
Int Creatlist (Sqlist L)
Int Getelem (Sqlist L, int, int & amp; E)
These Sqlist should not be quoted? CodePudding user response:
Int Initlist (Sqlist & amp; L) {
L.l ength=0;
return 1;
}
Int Creatlist (Sqlist & amp; L) {
int i;
Cout & lt; <"Please enter:" & lt; For (I=0; I & lt; 10; I++) {
Cin & gt;> L.d ata [I];
L.l ength++;
}
return 1;
}
Int Getelem (Sqlist & amp; L, int, int & amp; E) {
E=L.d ata [I - 1);
return 1;
}
CodePudding user response:
The