C++ HELP?!?!?!
13 years ago
does anyone know C++..... i really really need some help :(
i can email you more indepth if you can help
and the output its giving me is
{name
name
name
10
10
10
10
.
.
.
.
.
0
name
name
(nothing)
0
0
0
0
.
.
.
.
.
0
(nothing)
name
(Nothing)
0
0
0
0
.
.
.
.
.
0
This is my code
#include <iostream>
#include <string>
#include <ostream>
#include <fstream>
#include <cmath>
#include <stack>
#include <stdio.h>
using namespace std;
ofstream out_stream;
ifstream in_stream;
struct student{
string id;
string lvl;
string name;
int grades[10];
float avg;
};
student studs[15];
int main (){
const int size = 50;
string nt;
int i = 0;
int e = 0;
in_stream.open("NameStruct.txt");{
for (int e=0; e<3; e++){
getline(in_stream, studs[e].id);
getline(in_stream, studs[e].lvl);
getline(in_stream, nt);
studs[e].name=nt;
for (i=0; i<9; i++){
in_stream >> studs[e].grades[i];
}
studs[e].avg = 0;
}
}
in_stream.close();
for (e=0; e<3; e++){
cout << studs[e].id << endl;
cout << studs[e].lvl << endl;
cout << studs[e].name << endl;
for (i=0; i<9; i++){
cout << studs[e].grades[i] << endl;
}
cout << studs[e].avg << endl;
}
return 0;
}
i can email you more indepth if you can help
and the output its giving me is
{name
name
name
10
10
10
10
.
.
.
.
.
0
name
name
(nothing)
0
0
0
0
.
.
.
.
.
0
(nothing)
name
(Nothing)
0
0
0
0
.
.
.
.
.
0
This is my code
#include <iostream>
#include <string>
#include <ostream>
#include <fstream>
#include <cmath>
#include <stack>
#include <stdio.h>
using namespace std;
ofstream out_stream;
ifstream in_stream;
struct student{
string id;
string lvl;
string name;
int grades[10];
float avg;
};
student studs[15];
int main (){
const int size = 50;
string nt;
int i = 0;
int e = 0;
in_stream.open("NameStruct.txt");{
for (int e=0; e<3; e++){
getline(in_stream, studs[e].id);
getline(in_stream, studs[e].lvl);
getline(in_stream, nt);
studs[e].name=nt;
for (i=0; i<9; i++){
in_stream >> studs[e].grades[i];
}
studs[e].avg = 0;
}
}
in_stream.close();
for (e=0; e<3; e++){
cout << studs[e].id << endl;
cout << studs[e].lvl << endl;
cout << studs[e].name << endl;
for (i=0; i<9; i++){
cout << studs[e].grades[i] << endl;
}
cout << studs[e].avg << endl;
}
return 0;
}
if this is something you can post in public. ^^
1) what were the results you wanted to get
2) contains the file NameStruct.txt
hit me up on an IM, i've got all the details on my user page ;)