yeah, I took your code apart basically, here's a working version of what you had, although I'm pretty sure the logic isn't what you intended:
basically, it only takes the last line of the code because of that loop in the function. You're going to have to rework the entire thing to get it to do what you want. you still have a good amount of work ahead of you on this one.
#include <iostream> //for console IO
#include <fstream> //for file IO
#include <string> //for the string class
struct mainStruct //this holds our data
std::string name; //it contains a name
std::string time; //and a time
void ReadMainData(mainStruct& mouse); //read in the data
//std::ofstream out; //you never used this...
mainStruct mouse; //instantiate a struct
//you do realize that after this runs, you'll be left with the last name
//in the data file, right?
ReadMainData(mouse); //you don't specify datatype when calling
std::cout<<mouse.name; //output a name
void ReadMainData(mainStruct& mouse)
std::fstream input("test.in",std::ios::in); //open the file for reading
char*line=new char; //create space for a char*
while(input.get(line,25)) //take in the 25-char name
mouse.name.assign(line); //assign the name to the string in the struct
getline(input,mouse.time,' '); //take in and assign the time to the struct
input.ignore(32000,'\n'); //ignore up to the next newline
input.close(); //close the input file
deleteline; //free the memory from the char*
std::cout<<mouse.time<<std::endl; //ouptut the time (consider relocating this)
This is the data file I came up with based on the instructions:
of course, that may be off, meaning you'd have to tweak the function a little bit just to get it working the way it does now.
firstnameand lastname25a00:00:00:00 25
firstnameand lastname25b00:00:00:00 25
firstnameand lastname25c00:00:00:00 25
firstnameand lastname25d00:00:00:00 25