/* Main funktion */
{ here is struct }
int print(Student, int num)
int main()
{
Student info;
constint max = 20;
int num;
cout << "How many x you want: ";
cin >> num;
for (int nro = 0; nro < num; nro++)
{
Here is many lines
}
print(info, num);
return 0;
}
int print(Student info, int num)
{
float grade;
float totalgrade;
if (info.Struct1 = ...)
{
lines
}
elseif (info.Struct1 = ...)
{
lines
}
totalgrade = rules here;
for (int nro = 0; nro < num; nro++)
{
Here we print what we asked in main section
}
return 0;
}
The problem is that the sub program does not print the data entered by the user in the order they should appear in the main program loop. If the user enters at least 2 data; data x and y, then the sub program prints x data two times.
I really hope someone understand my horrible english and understood my problem.
Although you have made a valiant attempt to cut your code down it does not work. It is best to post code that can be compiled and tested so anyone working on it can see how it works and what it is doing.
/* Main funktion */
{ here is struct } // <--- What does it look like?
int print(Student, int num) // <--- Nice start for a forward declaration or prototype, but fails. Needs a ;.
int main()
{
Student info;
constint max = 20; // <--- What is this used for?
int num{}; // Always a good idea to initialize your variables.
cout << "How many x you want: ";
cin >> num;
for (int nro = 0; nro < num; nro++)
{
Here is many lines // <--- What are they?
}
print(info, num);
return 0;
}
int print(Student info, int num)
{
float grade;
float totalgrade;
if (info.Struct1 = ...) // <--- = means set, which will not work, and == means compare, still will not work.
{
lines
}
elseif (info.Struct1 = ...)
{
lines
}
totalgrade = rules here;
for (int nro = 0; nro < num; nro++)
{
Here we print what we asked in main section
}
return 0;
}
Prefer to use "double"s over "float"s.
You need to post the whole code so I can have a better idea of what it is doing.