Ok so im having some trouble trying to figure out how to read a line from a txt file which ive incorporated my C knowledge about reading a txt file into this main file. apparently im getting it wrong and Im almost confused. any help would be nice. posting my files in order of txt file, main, .cpp file, .h file, errors.

842 M C 20.00 15 2 250 10.00 UC RosebudTheatre 90 0 95 60 One Mike Stand
990 E C 20.00 19 2 1250 10.00 TX TexasHall 75 4 A 825 Maverick Speaker Series
554 C N 16.45 30 1 35 0.00 UC PaloDuraLounge 60 0 20 12 Global Grounds Coffee Hour
318 E C 18.00 3 4 350 0.00 NH 100 75 4 B 200 Engineering Speaker Series
842 M C 20.00 16 4 250 10.00 UC RosebudTheatre 90 0 100 75 One Mike Stand
4 V N 9.00 26 4 2000 0.00 LIB LibraryMall 240 5 25 120 The Big Event
868 M N 10.00 2 4 600 0.00 SAC 108 360 3 500 320 Art Glass Sale
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> 
#include <ctype.h>
#include "UTAevent.h"

using namespace std;

#define TRUE 1
#define FALSE 0
#define EVENTMAX 10
#define EVENTMIN 0

int main()
{
	int answer, index=0;
	
	UTAevent Event[EVENTMAX];
	UTAevent NEW[1];
	FILE *fp;
	std::cout<<
		"\n++++++++++ Event Registry ++++++++++\n\n"
		"This program is built to help the user with\n"
		"sort, searching, and printing school events\n"
		"that are going on around their school, home, or\n"
		"business. Due to limited memory, you are only\n"
		"allowed to have a maximum of 10 events. This\n"
		"will fix this in the next update.\n\n";
	if(( fp = fopen("uta.txt", "r")) == NULL){
		std::cout<<
			"Input file could not be opened!\n";
	}
	while (!feof(fp)){
		while(index > EVENTMIN && index < EVENTMAX){
			NEW[0] = Event[index];
		}
		fscanf(fp, "%d %c %c %f %d %d %d %f %s %d %d %d %d", NEW.set_number, NEW.set_purpose, NEW.set_type, NEW.set_cost, NEW.set_day, NEW.set_month, NEW.set_size, NEW.set_time, NEW.set_building, NEW.set_room, NEW.set_length,NEW.set_goal, NEW.set_target);
		fgetline(fp,tstr, tstrcount);
		strcpy(NEW::set_name, tstr);		
		index++;
	}
	std::cout<< 
		"\n++++++++++++ Main Menu ++++++++++++\n\n"
		"1:\t\tSort\n"
		"2:\t\tSearch\n"
		"3:\t\tPrint the data in the array\n"
		"4:\t\tEnd the program\n"
		"\n\nPlease Choose the number associated with your option.\n";
	cin>>answer;
	if (answer == 1){			// Sort

	}
	else if (answer == 2){		// Search

	}
	else if (answer == 3){		// Print the event
		int count = index;
		for (index = 0; index < count; index++){
			
		}
	}
	else if (answer == 4){		// END PROGRAM
		std::cout<<
			"Thank you for using this program!\n";
	}
	return 0;
}
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> 
#include <ctype.h>
#include "UTAevent.h"

UTAevent::UTAevent()
{
	number = 0;
	name = new char[1];
	name[0]= '0';
	type = ' ';
	purpose = ' ';
	time = 00.00;
	day = 0;
	month = 0;
	size = 0;
	cost = 0.00;
	building = new char[1];
	building[0] = '0';
	room = new char[1];
	room[0] = '0';
	length = 0;
	totalCost = 0.0;
}
void UTAevent::display() const{
	std::cout << "EVENT\n";
}
bool UTAevent::set_totalCost(float tot){
	if (tot >= 0){
		float addcost = tot;
		totalCost = totalCost + tot;
		return true;
	}
	else
		return false;
}
bool UTAevent::set_number(int num){
	int answer = num;
	if (answer == 842 || answer == 110 || answer == 120 || answer == 130 || answer == 140 || answer == 500 || answer == 803 || answer == 810 || answer == 874 || answer == 990 || answer == 318 || answer == 337 || answer == 301 || answer == 554 || answer == 868 || answer == 935 || answer == 4 || answer == 8 || answer == 10){
		number = num;
		return true;
	}
	else
		return false;
}
char UTAevent::set_name(char *nam){
	name = new char[ strlen(nam)+1];
	strcpy(name , nam);
	return true;
}
bool UTAevent::set_type(char typ){
	char charanswer = typ;
	if (charanswer == 'c' || charanswer == 'C'){
		type = 'C';
		return true;
	}
	else if (charanswer == 'S'|| charanswer == 's'){
		type = 'S';
		return true;
	}
	else if (charanswer == 'P'|| charanswer == 'p'){
		type = 'P';
		return true;
	}
	else if (charanswer == 'N'|| charanswer == 'n'){
		type = 'N';
		return true;
	}
	else if (charanswer == 'D'|| charanswer == 'd'){
		type = 'D';
		return true;
	}
	else if (charanswer == 'l'|| charanswer == 'L'){
		type = 'L';
		return true;
	}
	else if (charanswer == 'b'|| charanswer == 'B'){
		type = 'B';
		return true;
	}
	else if (charanswer == 'o'|| charanswer == 'O'){
		type = 'O';
		return true;
	}
	else
		return false;
}
bool UTAevent::set_purpose(char purp){
	char charanswer = purp;
	if (charanswer == 'F' || charanswer == 'f'){
		purpose = 'F';
		return true;
	}
	else if (charanswer == 'm'|| charanswer == 'M'){
		purpose ='M';
		return true;
	}
	else if (charanswer == 'C'|| charanswer == 'c'){
		purpose ='C';
		return true;
	}
	else if (charanswer == 'S'|| charanswer == 's'){
		purpose ='S';
		return true;
	}
	else if (charanswer == 'v'|| charanswer == 'V'){
		purpose ='V';
		return true;
	}
	else if (charanswer == 'l'|| charanswer == 'L'){
		purpose ='L';
		return true;
	}
	else if (charanswer == 'E'|| charanswer == 'e'){
		purpose ='E';
		return true;
	}
	else if (charanswer == 'A'|| charanswer == 'a'){
		purpose ='A';
		return true;
	}
	else if (charanswer == 'O'|| charanswer == 'o'){
		purpose ='O';
		return true;
	}
	else if (charanswer == 'P'|| charanswer == 'p'){
		purpose ='P';
		return true;
	}
	else
		return false;
}
bool UTAevent::set_time(float tim){
	int hrpart = (int)tim;
	int minpart = ((int)(tim*100)%100);
	if ((hrpart <= 24 || hrpart >=0) && (minpart <=60 || minpart >=0)){
		if (hrpart ==24&& minpart==0){
			return  true;
			time = tim;
		}
		else if(hrpart<24)
		{
			return true;
			time = tim;
		}
		else{
			return false;
		}
	}
	else{
		return false;
	}
}
bool UTAevent::set_day(int days){
	if (days < 0 && days >= 31){
		day = days;
		return true;
	}
	return false;
}
bool UTAevent::set_month(int mon){
	if (mon > 0 && mon <= 12){
		month = mon;
		return true;
	}
	return false;
}
bool UTAevent::set_size(int siz){
	if (siz >= 0 ){
		size = siz;
		return true;
	}
	return false;
}
bool UTAevent::set_cost(float cos){
	if (cos >=0 ){
		cost = cos;
		return true;
	}
	return false;
}
char UTAevent::set_building(char *bui){
	building = new char[ strlen(bui) + 1];
	strcpy(building, bui);
	return true;
}
char UTAevent::set_room(char *roo){
	room = new char[ strlen(roo) + 1];
	strcpy(room, roo);
	return true;
}
bool UTAevent::set_length(int len){
	if (len >= 0 && len <=60){
		length = len;
		return true;
	}
	return false;
}
bool UTAevent::set_predict(int pre){
	return true;
}
UTAevent::~UTAevent(void)
{
	delete [] name;
}
using namespace std;
#ifndef HEADER_FILE_H
#define HEADER_FILE_H

class UTAevent
{
public:
	UTAevent();
	//PRECONDITION: none
	//
	//POSTCONDITION: The data members of the object have
	//				 been initialized to default values.
	~UTAevent();
	//PRECONDITION: none
	//
	//POSTCONDITION: the employee is properly destroyed.
	//
	bool set_number(int num);
	//PRECONDITION: num must be a positive num that is associated with a
	//				specific event.
	//POSTCONDITION: number has been set to num.
	//
	char set_name(char *nam);
	//PRECONDITION: none
	//
	//POSTCONDITION: the name associated with a specific event has been set.
	//
	bool set_type(char typ);
	//PRECONDITION: typ must be of one of the specified event types.
	//
	//POSTCONDITION: the character code of the event type has been set.
	//
	bool set_purpose(char purp);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, purp has been added. if
	//				the return value is false, purp was not added.
	bool set_time(float tim);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, tim has been added. if
	//				the return value is false, tim was not added.
	bool set_day(int days);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, days has been added. if
	//				the return value is false, days was not added.
	bool set_month(int mon);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, mon has been added. if
	//				the return value is false, mon was not added.
	bool set_size(int siz);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, siz has been added. if
	//				the return value is false, siz was not added.
	bool set_cost(float cos);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, cos has been added. if
	//				the return value is false, cos was not added.
	char set_building(char *bui);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, *bui has been added. if
	//				the return value is false, *bui was not added.
	char set_room(char *roo);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, roo has been added. if
	//				the return value is false, roo was not added.
	bool set_length(int len);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, len has been added. if
	//				the return value is false, len was not added.
	bool set_predict(int pre);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, pre has been added. if
	//				the return value is false, pre was not added.
	bool set_totalCost(float tot);
	//PRECONDITION: none
	//
	//POSTCONDITION: if the return value is true, tot has been added. if
	//				the return value is false, tot was not added.
	int get_number() const { return number; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the event number is returned
	//
	const char * get_name() const { return name; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the event name is returned
	//
	char get_type() const { return type; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the event type is returned
	//
	char get_purpose() const { return purpose; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the event purpose is returned
	//
	float get_time() const { return time; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the event time is returned
	//
	int get_day() const { return month; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the day of the event is returned
	//
	int get_month() const { return month; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the event month is returned
	//
	int get_size() const { return size; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the event size is returned
	//
	float get_cost() const { return cost; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the cost of the event is returned
	//
	const char * get_building() const { return building; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the building is returned
	//
	const char * get_room()const { return room; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the room number is returned
	//
	int get_length() const { return length; }
	//PRECONDITION: none
	//
	//POSTCONDITION: the length is returned
	//
	int get_predict() const { return predict;}
	//PRECONDITION: none
	//
	//POSTCONDITION: the attendance prediction is returned
	//
	float get_totalCost() const { return totalCost;}
	//PRECONDITION: none
	//
	//POSTCONDITION: the total cost is returned
	//
	void display() const;
	//PRECONDITION: none
	//
	//POSTCONDITION: the id and number in inventory
	//				have been displayed on standard output
	#endif //HEADER_FILE_H
private:
	int number, size, length, predict;
	char *name;
	unsigned month : 4;
	unsigned day : 5; 
	char *room;
	char type, purpose; 
	char *building;
	float cost, time, totalCost;
	enum goal {networking, recruiting, Cfund, Gfund, talent, service}goal;
	union target 
	{	
		int service, recruiting, networking;
		float funds;
		char grade;
	}target;
};
Error	2	error C2228: left of '.set_number' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	3	error C2228: left of '.set_purpose' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	4	error C2228: left of '.set_type' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	5	error C2228: left of '.set_cost' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	6	error C2228: left of '.set_day' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	7	error C2228: left of '.set_month' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	8	error C2228: left of '.set_size' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	9	error C2228: left of '.set_time' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	10	error C2228: left of '.set_building' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	11	error C2228: left of '.set_room' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	12	error C2228: left of '.set_length' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	13	error C2228: left of '.set_goal' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	14	error C2228: left of '.set_target' must have class/struct/union	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	38	
Error	15	error C2065: 'tstr' : undeclared identifier	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	39	
Error	16	error C2065: 'tstrcount' : undeclared identifier	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	39	
Error	17	error C3861: 'fgetline': identifier not found	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	39	
Error	18	error C2825: 'NEW': must be a class or namespace when followed by '::'	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	40	
Error	19	error C2039: 'set_name' : is not a member of '`global namespace''	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	40	
Error	20	error C2146: syntax error : missing ')' before identifier 'set_name'	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	40	
Error	21	error C2660: 'strcpy' : function does not take 1 arguments	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	40	
Error	22	error C2059: syntax error : ')'	c:\users\tyler\documents\visual studio 2005\projects\lab 4\uta.cpp	40

By the way, im making the events to be set in an array. also the rest of the program isnt finish but I will be finishing that once I get the File input working. thanks for the help in advance

When reading an integer with scanf or fscanf, you need to provide it with the address of an integer. You have NEW defined as an array of size 1 (why not just a plain old single object?), so you want to dereference it, then specify which data member, then give the address, so something like this, I think:

fscanf(fp, "%d", &(NEW[0].set_number);
NEW is the array.
NEW[0] is an object.
NEW[0].set_number is an integer.
&(NEW[0].set_number) is the address of an integer.

Actually, set_number ISN't an integer, it's a function. number is an integer. set_number is a function, so do something like this:

int someNumber;
fscanf (fp, "%d", &someNumber);
NEW[0].set_number (someNumber);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.