File Input <fstream>

I am trying to get a couple variables from a file but it is not reading it correctly...
1
2
3
4
5
6
7
8
9
10
11

string stu_name, stu_strt_address, stu_zip;
float credit_cost, credit_num;


student_files >> cred_num;
getline (student_files, stu_name);
getline (student_files, stu_strt_address);
getline (student_files, stu_zip);
student_files >> credit_cost;


This is the data in student-files.txt

5
Quick Learner
123 Count Road
Kenyon, CA 11111
540.03

I am trying to get

5 = cred_num
Quick Learner = stu_name
123 Count Road = stu_strt_address
Kenyon, CA 11111 = stu_zip
540.03 = credit_cost

this is what happened
5 = cred num
=stu_name //nothing
=stu_strt_address //nothing
Quick Learner = stu_zip
123 = credit_cost
Last edited on
1
2
3
4
5
6
student_files >> cred_num;
student_files >> ws;
getline (student_files, stu_name);
getline (student_files, stu_strt_address);
getline (student_files, stu_zip);
student_files >> credit_cost;
Topic archived. No new replies allowed.