So i made 2 programs one is suppose to send data to a data file and the other is suppose to retrieve the data. i noticed that when it retrived data it only came up with the first word so i opened the data file and it only had the first word of everything i typed in. My teacher said something about using getline instead of cin but i cant figure out how to use it or even if thats what im suppose to do pls help.
Heres my program that sends data to the file
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
Change the cin's like cin >> name; to getline(cin, name); cin is the input method and name is the variable you would like to store in.
Basically getline can read more then one word where cin only reads one word because it stops at white spaces.
That should solve that problem though I haven't looked through the rest of your code. Let me know if you don't understand anything or need more help.
I'll leave that for you to figure out :) Hint: It is almost the same as the first question you asked. Just do some research on it and I am sure you will have no problem figuring it out.