Printing several arrays by calling 1 array!

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

30 Replies - 1077 Views - Last Post: 02 October 2012 - 09:03 PM Rate Topic: -----

#1 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Printing several arrays by calling 1 array!

Posted 21 September 2012 - 08:34 AM

Hey I am confused with an essential part I am makeing a flight registry using struct, arrays & data types.

I wrote the code I just do not know how to establish an array that refers to other arrays this is a test code not the real one

#include <iostream>
#include <iomanip>
#include <string>
 
using namespace std;

enum HealthType { Poor, Fair, Good, Excellent } ;
////struct method///
struct StudentType{ 
    // declares a struct data type
    // does not allocate memory
	long id;
	string firstname, lastname;
	string school; 
	string major;
	int age;
	float weight;
	HealthType health;
};
///////prints health////////
void PrintWord(HealthType health){
	string msg;

	switch (health) {
		case Poor: msg = "Poor"; break;
		case Fair: msg = "Fair"; break;
		case Good: msg = "Good"; break; 
		case Excellent: msg = "Excellent"; break;
	}
	cout << msg;
}
////prints all students//////////
void PrintallStudents(StudentType allStudents[], int size){
	for (int i=0;i< size; i++)
		PrintStudentData(allStudents[i]);
}
/////prints one student that is selected/////////
void PrintStudentData( StudentType aStudent)
     // Prints out values of all members of aStudent
     // Precondition: all members of aStudent are assigned
     // Postcondition: all members have been written out
{
	cout <<"__________________________________________________________" << endl;
	cout << setw(25)<< "ID #: " << aStudent.id <<endl;
	cout << setw(25)<< "First and Last Name: " << aStudent.firstname << " " << aStudent.lastname << endl;
	cout << setw(25)<< "School and Major: "<< aStudent.school << aStudent.major << endl;
	cout << setw(25)<< "Age: " << aStudent.age << "years " << endl;
	cout << setw(25)<< "Weight: "<< aStudent.weight << " lbs. " << endl;
	cout << setw(25)<< "General health : ";
	PrintWord ( aStudent.health );
	cout << endl;
	cout << "__________________________________________________________" << endl;
}

////////////Here is the get data where I enter the data///////////REFERENCE TO QUESTION/
StudentType GetStudentData ( void ) {
   // Obtains all information about a student from keyboard
   // Postcondition:
   // Function value = StudentType members entered at keyborad
	int res; 
	StudentType aStudent ;
	
	cout<<"\nEnter student's info.."<<endl;

	cout << setw(20) << "ID: "; cin>> aStudent.id;
	cout << setw(20) << "First Name: "; cin>> aStudent.firstname;
	cout << setw(20) << "Last Name: "; cin>> aStudent.lastname;
	cout << setw(20) << "School: "; 	cin>> aStudent.school;
	cout << setw(20) << "Major: "; 	cin>> aStudent.major;
	cout << setw(20) << "Age: "; 	cin>> aStudent.age;
	cout << setw(20) << "Weight: "; 	cin>> aStudent.weight;
	cout << setw(10) << "(Poor=0,Fair=1,Good=2,Excellent=3)" << endl;
	cout << setw(20) << "Health Type: ";
	cin>> res; aStudent.health = (HealthType) res;

	return aStudent ;
}
//////sort students using swap method///////
void swap(StudentType *std1, StudentType *std2){
       StudentType  hold = *std1;
      *std1 = *std2;
      *std2 = hold;
}
/////////sort students using bubblesort method//////////////
void bubbleSort(StudentType allStudents[], const int size){
	int choice;
    for (int pass=0; pass<size-1; pass++)
        for (int k=0; k<size-1; k++)   
             if (allStudents[k].id > allStudents[k+1].id)
                 swap(&allStudents[k], &allStudents[k+1]);
}


////////main//////////////
int main(int argc, char* argv[])
{
	StudentType aStudent, allStudents[10];
	int nbStudents = 0;
	char moreData = 'Y';

	while(moreData=='Y') {
		aStudent = GetStudentData();
		allStudents[nbStudents] = aStudent;
		nbStudents++;
		bubbleSort( allStudents, nbStudents ); 
		cout << "\nThe information you entered is:" << endl;
		PrintallStudents(allStudents, nbStudents);
		PrintStudentData(aStudent);
		cout << endl << "More data?(y/n): ";
		cin >> moreData;
		moreData =(moreData=='y'?'Y':moreData);
	}

	return 0;
}



I hope you understand the code so that I do not need spent most of the time explaining codes I already know.
The problem is simple I want an array to call upon other arrays. I already did a similar function in the getfuncion that has the reference to question label. astudents.id is an example of an array of astudents calling id which is inside the datatype studenttype. Problem is if I want for example to type the id of the function cin>>id; I want it to print or cout all data of data of student like age, major, health, fname, lastname etc.

Is This A Good Question/Topic? 0
  • +

Replies To: Printing several arrays by calling 1 array!

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 765
  • View blog
  • Posts: 2,227
  • Joined: 20-March 10

Re: Printing several arrays by calling 1 array!

Posted 21 September 2012 - 10:12 AM

Well if the test code was better organised it would work,


main.cpp
#include "functions.h"
using namespace std;





////////main//////////////
int main(int argc, char* argv[])
{
	StudentType aStudent, allStudents[10];
	int nbStudents = 0;
	char moreData = 'Y';

	while(moreData=='Y') {
		aStudent = GetStudentData();
		allStudents[nbStudents] = aStudent;
		nbStudents++;
		bubbleSort( allStudents, nbStudents );
		cout << "\nThe information you entered is:" << endl;
		PrintallStudents(allStudents, nbStudents);
		PrintStudentData(aStudent);
		cout << endl << "More data?(y/n): ";
		cin >> moreData;
		moreData =(moreData=='y'?'Y':moreData);
	}

	return 0;
}





functions.cpp
#include "functions.h"

///////prints health////////
void PrintWord(HealthType health){
	string msg;

	switch (health) {
		case Poor: msg = "Poor"; break;
		case Fair: msg = "Fair"; break;
		case Good: msg = "Good"; break;
		case Excellent: msg = "Excellent"; break;
	}
	cout << msg;
}
void PrintStudentData( StudentType aStudent)
     // Prints out values of all members of aStudent
     // Precondition: all members of aStudent are assigned
     // Postcondition: all members have been written out
{
	cout <<"__________________________________________________________" << endl;
	cout << setw(25)<< "ID #: " << aStudent.id <<endl;
	cout << setw(25)<< "First and Last Name: " << aStudent.firstname << " " << aStudent.lastname << endl;
	cout << setw(25)<< "School and Major: "<< aStudent.school << aStudent.major << endl;
	cout << setw(25)<< "Age: " << aStudent.age << "years " << endl;
	cout << setw(25)<< "Weight: "<< aStudent.weight << " lbs. " << endl;
	cout << setw(25)<< "General health : ";
	PrintWord ( aStudent.health );
	cout << endl;
	cout << "__________________________________________________________" << endl;
}

////prints all students//////////
void PrintallStudents(StudentType allStudents[], int size){
	for (int i=0;i< size; i++)
		PrintStudentData(allStudents[i]);
}
/////prints one student that is selected/////////

////////////Here is the get data where I enter the data///////////REFERENCE TO QUESTION/
StudentType GetStudentData ( void ) {
   // Obtains all information about a student from keyboard
   // Postcondition:
   // Function value = StudentType members entered at keyborad
	int res;
	StudentType aStudent ;

	cout<<"\nEnter student's info.."<<endl;

	cout << setw(20) << "ID: "; cin>> aStudent.id;
	cout << setw(20) << "First Name: "; cin>> aStudent.firstname;
	cout << setw(20) << "Last Name: "; cin>> aStudent.lastname;
	cout << setw(20) << "School: "; 	cin>> aStudent.school;
	cout << setw(20) << "Major: "; 	cin>> aStudent.major;
	cout << setw(20) << "Age: "; 	cin>> aStudent.age;
	cout << setw(20) << "Weight: "; 	cin>> aStudent.weight;
	cout << setw(10) << "(Poor=0,Fair=1,Good=2,Excellent=3)" << endl;
	cout << setw(20) << "Health Type: ";
	cin>> res; aStudent.health = (HealthType) res;

	return aStudent ;
}
//////sort students using swap method///////
void swap(StudentType *std1, StudentType *std2){
       StudentType  hold = *std1;
      *std1 = *std2;
      *std2 = hold;
}
/////////sort students using bubblesort method//////////////
void bubbleSort(StudentType allStudents[], const int size){
	//int choice;
    for (int pass=0; pass<size-1; pass++)
        for (int k=0; k<size-1; k++)
             if (allStudents[k].id > allStudents[k+1].id)
                 swap(&allStudents[k], &allStudents[k+1]);
}




functions.h
#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
enum HealthType { Poor, Fair, Good, Excellent } ;
////struct method///
struct StudentType{
    // declares a struct data type
    // does not allocate memory
	long id;
	string firstname, lastname;
	string school;
	string major;
	int age;
	float weight;
	HealthType health;
	void PrintStudentData( StudentType aStudent);
	void PrintallStudents(StudentType allStudents[], int size);
	void PrintWord(HealthType health);
};
void PrintWord(HealthType health);
void PrintStudentData( StudentType aStudent);
void PrintallStudents(StudentType allStudents[], int size);
StudentType GetStudentData ( void );
void swap(StudentType *std1, StudentType *std2);
void bubbleSort(StudentType allStudents[], const int size);

#endif // FUNCTIONS_H_INCLUDED



Perhaps code organisation is what is holding you back in the real code.

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#3 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Re: Printing several arrays by calling 1 array!

Posted 22 September 2012 - 05:40 AM

View Postsnoopy11, on 21 September 2012 - 10:12 AM, said:

Well if the test code was better organised it would work,

Perhaps code organisation is what is holding you back in the real code.

Snoopy.

well thank you for spliting them in files but that does nothing unfortunately. I can organize them but that is not my question nor it could change the result for there are things that headers are restricted to do. Anyways I hope you can help me understand how can I call 1 element from astudent that is id to call upon the rest of the details that are for the same student note that every student has a similar array number so it is easy but I can't figure out how to do it. Reminder I want 1 element that from astudent that is part of the datatype StudentsType that is ID when written in a cin then the output would be the entire array of the student. So if I type the ID the entire data of the student should show I hope I am clear with this my problem is not with organization but with calling out an array to print several arrays fom 1 user.
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,742
  • Joined: 05-May 12

Re: Printing several arrays by calling 1 array!

Posted 22 September 2012 - 09:39 AM

Quote

Reminder I want 1 element that from astudent that is part of the datatype StudentsType that is ID when written in a cin then the output would be the entire array of the student.


I can see part of the reason for the misunderstanding: incorrect terminology You are using the phrase "entire array of the student" when referring to the the "datatype StudentsType". StudentsType is a struct. I think that your refusal to learn about structs from back in June is still having some lingering echoes. id, firstname, lastname, etc. are called members or member variables.

The second part of the misunderstanding. incorrect concept vs intended code. You said:

Quote

Problem is if I want for example to type the id of the function cin>>id; I want it to print or cout all data of data of student like age, major, health, fname, lastname etc.

cin >> ... is meant to input data, yet you are asking to print out the data. Perhaps you meant to say cout << id ?

Now on to the core problem. There is no easy, sane way to do what you want. Or at least no way to do it and not have your others who read your code, go WTF?!?!? and post your code on thedailywtf.com.

Think for a moment. Given the code:
cin >> id;


How will the compiler magically know that in this case when you are using cin >>, you actually want the code to print out instead of output data?

So let's move on and assume that you actually wrote:
cout << id;


How will the compiler magically know that id is a member of StudentsType struct, and furthermore, also know that it should use the allStudents array? What's supposed to happen if you happened to have:
struct Pet
{
    string name;
    int weight;
};

struct Politician
{
    string name;
    int IQ;
};

Pet myPets[10];
Politician myPolicticians[10];

void PrintPet(string name)
{
    cout << name;
}

void PrintPolititian(string name)
{
    cout << name;
}



No current C++ compiler can read your mind and know what your intent is. (Although I've been told that there are some Visual Studio plugins that come amazingly close, but that's an aside.)

Spoiler

Was This Post Helpful? 0
  • +
  • -

#5 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Re: Printing several arrays by calling 1 array!

Posted 22 September 2012 - 10:00 AM

View PostSkydiver, on 22 September 2012 - 09:39 AM, said:

Quote

Spoiler



Sorry for being misunderstood. For the previous post I was supposed to do the project using class only struct was not allowed for the project, I thought I made myself clear last time. This is another project I must only use struct this time. Lets focus on this topic look I apologies again for not being clear. what I meant by cin>>id; is that if you type the id an if statment will compare all id's that have been typed within the execution of the code. So for example this is a method that I assume will work. note that this is part of the entire code so do not ask where did I define the integer or type within this code sample.
cin>>id;
if (id == astudent.id)
{
cout<<setw(20)<<"ID: "<<astudent.id<<"Major: "<<astudent.major<<"ID: "<<astudent.major<<"Age: "<<astudent.age;
else
{
cout<<"student ID does not exist";
}
}



I hope this logic is understandable & not magical or impossible. If there is a correct or better way to do this please explain how.

This post has been edited by busta5000: 22 September 2012 - 10:02 AM

Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,742
  • Joined: 05-May 12

Re: Printing several arrays by calling 1 array!

Posted 22 September 2012 - 10:26 AM

Ah! That makes more sense.

Using your array, you can't avoid looping to do the matching. Either you'll have to do the loop to search yourself, or you can use the Standard C++ Library to do the loop for you if you use std::find_if(): http://www.cplusplus...orithm/find_if/

Now on the other hand, if you used std::map<>, you could do something like:
map<int, StudentType> allStudents;

// Find a student by id
int id;
cin >> id;
if (allStudents.find(id) != allStudents.end())
{
    StudentType aStudend = allStudents[id];
    cout<<setw(20)<<"ID: "<<astudent.id<<"Major: "<<astudent.major<<"ID: "<<astudent.major<<"Age: "<<astudent.age;
}
else
{
    cout << "student ID does not exist" << endl;
}


This post has been edited by Skydiver: 22 September 2012 - 10:26 AM

Was This Post Helpful? 1
  • +
  • -

#7 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Re: Printing several arrays by calling 1 array!

Posted 22 September 2012 - 10:41 AM

View PostSkydiver, on 22 September 2012 - 10:26 AM, said:

Ah! That makes more sense.

Using your array, you can't avoid looping to do the matching. Either you'll have to do the loop to search yourself, or you can use the Standard C++ Library to do the loop for you if you use std::find_if(): http://www.cplusplus...orithm/find_if/

Now on the other hand, if you used std::map<>, you could do something like:
map<int, StudentType> allStudents;

// Find a student by id
int id;
cin >> id;
if (allStudents.find(id) != allStudents.end())
{
    StudentType aStudend = allStudents[id];
    cout<<setw(20)<<"ID: "<<astudent.id<<"Major: "<<astudent.major<<"ID: "<<astudent.major<<"Age: "<<astudent.age;
}
else
{
    cout << "student ID does not exist" << endl;
}




Thank you, but is it me or does the find_if is somehow similar to map<>. Anyways I will try the find_if first & will reply once it work.
Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,742
  • Joined: 05-May 12

Re: Printing several arrays by calling 1 array!

Posted 22 September 2012 - 10:51 AM

Yes, the functional effect is the same: you find an item. The implementation is different. The map is implemented as a tree behind the scenes and offers better search performance, than doing a linear search through an array using find_if().

If you used binary_search() you could get the same performance as the map<>, but you'll have to take time to sort your array, as well as jump through some hoops to get the search value and comparator written correctly. http://www.cplusplus.../binary_search/

Given a choice, I'd go with the find_if() as long as the array stays less than 100 elements.
Was This Post Helpful? 0
  • +
  • -

#9 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Re: Printing several arrays by calling 1 array!

Posted 29 September 2012 - 06:18 AM

Hey its me again this is the actual code I'm working on which is similar to the previous code.
Objective:
* Have 3 level nested structs.
* Provide a simple c++ application that manages flights it should have the capability to add, delete, search & list flights.
*Beside the errors that I have I want you to confirm the functionality and correctness of my code as well please.

unsorted list has the generic types like delete, retrieve etc.
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

/////////////////////////////Unsorted List//////////////////////////////////////////
template <class genType,  int MAX_ITEMS >
class UnsortedList { 
public:
	UnsortedList();
	void MakeEmpty();
	bool IsFull() const;
	int Length() const;
	void RetrieveItem(genType& item, bool& found);
	void InsertItem(genType item);
	void DeleteItem(genType item);
	void ResetList();
	void GetNextItem(genType& item);
private:
	int length;
	genType items[MAX_ITEMS];
	int currentPos;
};


3 level nested struct types
/////////////////////////////Struct Levels/////////////////////////////////////
struct FlightType{ 
	string id; //array id
};

struct CarrierType{
	string carrier[50]; //array carrier
	int capacity[50]; //array capacity
	string destination[50]; //array destination
	FlightType aFlight;
};

struct TimeType{
	CarrierType aCarrier;
	string departure[50]; //array departure
	string arrival[50]; //array arrival
	int date[50]; //current date or machine date to compare to departure or arrival
};


Display Menu
this is first interface when running the application
//////////////////////////////////Display Menu////////////////////////////////////////////
void DislayMenu(){
	cout<<"---------------------------------------------------------"<<endl;
	cout<<"Flight Management System (CSC301, Fall2012)"<<endl;
	cout<<"---------------------------------------------------------"<<endl;
	cout<<"1- Create a new flight"<<endl;
	cout<<"2- Delete a flight"<<endl;
	cout<<"3- List all flights"<<endl;
	cout<<"4- Check if a flight exists based on its ID"<<endl;
	cout<<"0- Quit"<<endl;
	cout<<"---------------------------------------------------------"<<endl;
}

int UserMenuChoice(){
	int choice = 1000;
	while(choice > 4) {
		cout<<"Your choice (0, 1, 2, 3, 4)?";
		cin>>choice;
	}
	return choice;
}


Create Flight
Adds elements in the arrays.
//////////////////////////////Create Flight/////////////////////////////////////////////////
void CreateFlight(/*FlightType aFlight, CarrierType aCarrier, TimeType aTime*/){
	cout<<"=================================================================";
	cout<<"==                          NEW  FLIGHT                        ==";
	cout<<"=================================================================";
	FlightType aFlight;
	CarrierType aCarrier; 
	TimeType aTime;
	cout<< setw(20)<<"ID: "; 
	cin>>aFlight.id[];
	cout<<setw(20)<<"Carrier: ";
	cin>>aCarrier.carrier[];
	cout<<setw(20)<<"Capacity: ";
	cin>>aCarrier.capacity[];
	cout<<setw(20)<<"Destination: "; 	
	cin>>aCarrier.destination[];
	cout<<setw(20)<<"Departure: "; 	
	cin>>aTime.departure[];
	cout<<setw(20)<<"Arrival: "; 	
	cin>>aTime.arrival[];
}


Delete Flight
This deletes a flight by typing the id it checks the array of id then it deletes every other thing related to the same array location.
In order to understand its simple the flight ticket is determined by id so the flight id is unique for every array so it will delete the other arrays that have the same location.
///////////////////////////////////Delete Flight///////////////////////////////////////////////////
template <class genType,  int MAX_ITEMS >
void DeleteFlight<genType, MAX_ITEMS>::DeleteItem(genType item){
	cin>>id[];
	bool found = false;
	int location=0
	for (; (location<length) && (!found); location++)
		if (id == aFlight.id[location]) found = true;
	if (found) {
		id[location] = id[length - 1];
                carrier[location] = carrier[length - 1];
                capacity[location] = capacity[length - 1];
                destination[location] = destination[length - 1];
                departure[location] = departure[length - 1];
                arrival[location] = arrival[length - 1];
		length--;
	}
}


List Flight
use flighttype to print all flights
/////////////////////////////////////List Flight///////////////////////////////////////////////////////////
void ListFlights(FlightType allFlights[], int size){
	cout<<"=================================================================";
	cout<<"==                         FLIGHT  LIST                        ==";
	cout<<"=================================================================";
	cout<<"please select available flights destination:";
	for (int i=0;i< size; i++){
	PrintFlightData(allFlights[i]);
	}
}
void PrintFlightData( FlightType aFlight, CarrierType aCarrier, TimeType Time)
{
	cout <<"__________________________________________________________" << endl;
	cout << setw(25)<< "ID #: " << aFlight.id <<endl;
	cout << setw(25)<< "Carrier: " << aCarrier.carrier << "Capacity: " << aCarrier.capacity <<"Destination: "<< aCarrier.destination<<endl;
	cout << setw(25)<< "School and Major: "<<aTime.departure << "Age: " << aTime.arrival <<endl;
	cout << "__________________________________________________________" << endl;
}


Search Flight
use retrieveitem to generic type to retrieve or search for flights
////////////////////////////////Search Flight/////////////////////////////////////////////////////////
template <class genType,  int MAX_ITEMS >
void SearchFlight <genType, MAX_ITEMS > :: RetrieveItem(genType& item,bool& found){
		cout<<"=================================================================";
		cout<<"==                          CHECK  FLIGHT                      ==";
		cout<<"=================================================================";
		cout<<"please type ID of flight to check if it exists:";
		FlightType aFlight;
		CarrierType aCarrier; 
		TimeType aTime;
		bool moreToSearch;
		int location=0;
		found = false;
		cin>>destination[];
		moreToSearch = (location < length);
		while (moreToSearch && !found) 	{
			if (destination == destination[location]) {
			found = true; 
			destination = destination[location];
		} else {
			location++;
			moreToSearch = (location<length);
		}
	}
}


Main
Simply runs all functions
//////////////////////main/////////////////////////////////////////
int main(int argc, char* argv[])
{
	int userChoice;
	do {
		system("cls");
		DislayMenu();
		userChoice = UserMenuChoice();
		switch (userChoice) {
			case 1: 
				CreateFlight(/*FlightType aFlight, CarrierType aCarrier, TimeType aTime*/); 
				break;
			case 2: 
				DeleteFlight(/*FlightType aFlight, CarrierType aCarrier, TimeType aTime*/); 
				break;
			case 3: 
				ListFlights(/*FlightType aFlight, CarrierType aCarrier, TimeType aTime*/); 
				break;
			case 4: 
				SearchFlight(/*FlightType aFlight, CarrierType aCarrier, TimeType aTime*/); 
				break;
			default:  cout<<"Thanks for using CSC301's Flight Managenment System. Good Bye.";
		}
	}while (userChoice != 0);
	return 0;
}



ERROR LOG
BTW ignore the C2059 error regarding the ]. I recently added this error by adding [] just in case I know its wrong but ignore that the [] is there in the error locations. I just wanted to add an array with the size of 50 so I know that in cin>>id[]; should be correct in a way.
Error	1	error C2059: syntax error : ']'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	75	1	Assig1
Error	2	error C2059: syntax error : ']'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	77	1	Assig1
Error	3	error C2059: syntax error : ']'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	79	1	Assig1
Error	4	error C2059: syntax error : ']'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	81	1	Assig1
Error	5	error C2059: syntax error : ']'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	83	1	Assig1
Error	6	error C2059: syntax error : ']'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	85	1	Assig1
Error	7	error C2143: syntax error : missing ';' before '<'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	90	1	Assig1
Error	8	error C2182: 'DeleteFlight' : illegal use of type 'void'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	90	1	Assig1
Error	9	error C2988: unrecognizable template declaration/definition	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	90	1	Assig1
Error	10	error C2059: syntax error : '<'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	90	1	Assig1
Error	11	error C2039: 'DeleteItem' : is not a member of '`global namespace''	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	90	1	Assig1
Error	12	error C2143: syntax error : missing ';' before '{'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	102	1	Assig1
Error	13	error C2447: '{' : missing function header (old-style formal list?)	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	102	1	Assig1
Error	14	error C2065: 'aTime' : undeclared identifier	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	116	1	Assig1
Error	15	error C2065: 'aTime' : undeclared identifier	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	116	1	Assig1
Error	16	error C2143: syntax error : missing ';' before '<'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	122	1	Assig1
Error	17	error C2182: 'SearchFlight' : illegal use of type 'void'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	122	1	Assig1
Error	18	error C2988: unrecognizable template declaration/definition	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	122	1	Assig1
Error	19	error C2059: syntax error : '<'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	122	1	Assig1
Error	20	error C2039: 'RetrieveItem' : is not a member of '`global namespace''	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	122	1	Assig1
Error	21	error C2143: syntax error : missing ';' before '{'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	146	1	Assig1
Error	22	error C2447: '{' : missing function header (old-style formal list?)	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	146	1	Assig1
	23	IntelliSense: identifier "DeleteFlight" is undefined	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	158	5	Assig1
	24	IntelliSense: too few arguments in function call	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	161	77	Assig1
	25	IntelliSense: identifier "SearchFlight" is undefined	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	164	5	Assig1



Beside the errors that I have I want you to confirm the functionality and correctness of my code as well please.

This post has been edited by busta5000: 29 September 2012 - 06:30 AM

Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon


Reputation: 3993
  • View blog
  • Posts: 12,323
  • Joined: 25-December 09

Re: Printing several arrays by calling 1 array!

Posted 29 September 2012 - 07:13 AM

Since you are using templates, both the definition and the implementation must be in the same compilation unit, usually in the same file. Where are the implementation for your template class? Many template classes are implemented completely in the header file.

Quote

BTW ignore the C2059 error regarding the ]. I recently added this error by adding [] just in case I know its wrong but ignore that the [] is there in the error locations.


Sorry but you need to fix these errors and then post the new error messages. Many times fixing one error will fix multiple error messages.


Jim
Was This Post Helpful? 0
  • +
  • -

#11 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Re: Printing several arrays by calling 1 array!

Posted 30 September 2012 - 12:59 PM

Sorry I always seem to change the code but I refused to use gentype since I felt it was unnececery & I could use the functions directly in-staid in deleting & searching. Problems have faced me that I could not determine hope you can explain
btw I am experimenting with my logic of understanding so there are things in which I do not know what to do like how to do a global variable for an datatype struct array. Also I do not know how to type the length of an open array that the size has not been determined.

* Edit:Fixed error log I forgot to clear solution & recompile


3 Level nested structs
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;
/////////////////////////////Struct Levels/////////////////////////////////////
struct FlightType{ 
	string id; //array id
	CarrierType aCarrier;
};

struct CarrierType{
	string carrier; //array carrier
	int capacity; //array capacity
	string destination; //array destination
	TimeType aTime;
};

struct TimeType{
	CarrierType aCarrier;
	string departure; //array departure
	string arrival; //array arrival
	//int date; //current date or machine date to compare to departure or arrival
};






//Global variable for datatype struct array
//#1 priority error I want a global variable to determine the element number of the struct array FlightType. Notice the difference between plural & single. Plural is global & single is the local
///////////////////////////////Global Variable///////////////////////////////////////////////
//Global variable for datatype struct array
//#1 priority error I want a global variable to determine the element number of the struct array FlightType. Notice the difference between plural & single. Plural is global & single is the local
FlightsType Flights[] = FlightType[1000]; //This line simply creates a global variable to use the array of structs. Problem is global variable is not detected its an error!
int Flightno = 0;  //global counter








//////////////////////////////////Display Menu////////////////////////////////////////////
void DislayMenu(){
	cout<<"---------------------------------------------------------"<<endl;
	cout<<"Flight Management System (CSC301, Fall2012)"<<endl;
	cout<<"---------------------------------------------------------"<<endl;
	cout<<"1- Create a new flight"<<endl;
	cout<<"2- Delete a flight"<<endl;
	cout<<"3- List all flights"<<endl;
	cout<<"4- Check if a flight exists based on its ID"<<endl;
	cout<<"0- Quit"<<endl;
	cout<<"---------------------------------------------------------"<<endl;
}

int UserMenuChoice(){
	int choice = 1000;
	while(choice > 4) {
		cout<<"Your choice (0, 1, 2, 3, 4)?";
		cin>>choice;
	}
	return choice;
}






//This simply adds values to the array so when this is executed flightno will be incremented noting that this is ticket 1.
//////////////////////////////Create Flight/////////////////////////////////////////////////
//This simply adds values to the array so when this is executed flightno will be incremented noting that this is ticket 1.
void CreateFlight(FlightsType Flights){
	cout<<"=================================================================";
	cout<<"==                          NEW  FLIGHT                        ==";
	cout<<"=================================================================";
	FlightType aFlight;
	cout<< setw(20)<<"ID: "; 
	cin>>aFlight.id;
	cout<<setw(20)<<"Capacity: ";
	cin>>aFlight.aCarrier.capacity;
	cout<<setw(20)<<"Destination: "; 	
	cin>>aFlight.aCarrier.destination;
	cout<<setw(20)<<"Departure: "; 	
	cin>>aFlight.aCarrier.aTime.departure;
	cout<<setw(20)<<"Arrival: "; 	
	cin>>aFlight.aCarrier.aTime.arrival;
	Flights[Flightno] = aFlight;
	Flightno++;
}





//This function lets the user input the id of the flight then it will determine the location then it will delete entire flights data with similar location like destination, arrival etc
//Its like a ticket if a Flight has been canceled then entire ticket is useless so the time & destination are canceled as well so this simply deletes the entire ticket.
///////////////////////////////////Delete Flight///////////////////////////////////////////////////
//This function lets the user input the id of the flight then it will determine the location then it will delete entire flights data with similar location like destination, arrival etc
//Its like a ticket if a Flight has been canceled then entire ticket is useless so the time & destination are canceled as well so this simply deletes the entire ticket.
void DeleteFlight(/*FlightsType[] aFlight*/){
	FlightsType[] aFlight;  //I tried to put it up in the brackets or down here it still doesn't work because it did not understand the global variable.
	//node that FlightType is different from FlighsType. The plural is the global the single is the local.
	string id;
	cin>>id;
	bool found = false;
	int location=0
	for (; (location<aaFlight.length) && (!found); location++) //problem with for loop
		if (id == (aFlight[location].id)) found = true;
	if (found) {
		aFlight[location] = aFlight[length - 1];//error since it did not detect global
		length--;
	}
}







//This lists all flights by calling the print function until the end of the array which is determined by flightno. Flightno is similar to int size, it is merely used as a counter.
/////////////////////////////////////List Flight///////////////////////////////////////////////////////////
//This lists all flights by calling the print function until the end of the array which is determined by flightno. Flightno is similar to int size, it is merely used as a counter.
void ListFlights(FlightsType Flights[], Flightno){// global var still not detected
	cout<<"=================================================================";
	cout<<"==                         FLIGHT  LIST                        ==";
	cout<<"=================================================================";
	cout<<"please select available flights destination:";
	for (int i=0;i< Flightno; i++){
	PrintFlightData(Flights[i]);/////This should print all students but this doesn't work since it did not detect global var.
	}
}
void PrintFlightData()//print fuction is fine
{
	FlightType aFlight;
	cout <<"__________________________________________________________" << endl;
	cout << setw(25)<< "ID #: " << aFlight.id <<endl;
	cout << setw(25)<< "Capacity: " << aFlight.aCarrier.capacity <<"Destination: "<< aFlight.aCarrier.destination<<endl;
	cout << setw(25)<< "School and Major: "<<aFlight.aCarrier.aTime.departure << "Age: " << aFlight.aCarrier.aTime.arrival <<endl;
	cout << "__________________________________________________________" << endl;
}








//this simply searches the function by id so if I type the id the print function will execute once & it will only print the ticket that has the same id.
////////////////////////////////Search Flight/////////////////////////////////////////////////////////
//this simply searches the function by id so if I type the id the print function will execute once & it will only print the ticket that has the same id.
void SearchFlight(){
		cout<<"=================================================================";
		cout<<"==                          CHECK  FLIGHT                      ==";
		cout<<"=================================================================";
		cout<<"please type ID of flight to check if it exists:";
		FlightType aFlight;
		bool moreToSearch;
		int location=0;
		bool found;
		found = false;
		int id;
		cin>>id;
		moreToSearch = (location < length);//I want it to search for every element within the array until the last location which is determined by the length. I have no idea.
		while (moreToSearch && !found) 	{
			if (id == aFlight[location].id) { //error
			found = true; 
			PrintFlightData(aFlight[location].id) //I did try aFlight.id[location] but my friend said its incorrect! since id is not an array but the whole struct is an array.
		} else {
			location++;
			moreToSearch = (location<length);//error btw I have no idea how to decide the length I tried length only I tried aFlight.length did not work 
		}
	}
}










//////////////////////main/////////////////////////////////////////
int main(int argc, char* argv[])
{
	int userChoice;
	do {
		system("cls");
		DislayMenu();
		userChoice = UserMenuChoice();
		switch (userChoice) {
			case 1: 
				CreateFlight(); 
				break;
			case 2: 
				DeleteFlight(); 
				break;
			case 3: 
				ListFlights(); 
				break;
			case 4: 
				SearchFlight(); 
				break;
			default:  cout<<"Thanks for using CSC301's Flight Managenment System. Good Bye.";
		}
	}while (userChoice != 0);
	return 0;
}




ERROR LOG
* Fixed error log I forgot to clear solution & recompile
Error	1	error C2146: syntax error : missing ';' before identifier 'aCarrier'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	9	1	Assig1
Error	2	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	9	1	Assig1
Error	3	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	9	1	Assig1
Error	4	error C2146: syntax error : missing ';' before identifier 'aTime'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	16	1	Assig1
Error	5	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	16	1	Assig1
Error	6	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	16	1	Assig1
Error	7	error C2146: syntax error : missing ';' before identifier 'Flights'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	28	1	Assig1
Error	8	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	28	1	Assig1
Error	9	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	28	1	Assig1
Error	10	error C2275: 'FlightType' : illegal use of this type as an expression	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	28	1	Assig1
Error	11	error C2146: syntax error : missing ')' before identifier 'Flights'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	53	1	Assig1
Error	12	error C2182: 'CreateFlight' : illegal use of type 'void'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	53	1	Assig1
Error	13	error C2059: syntax error : ')'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	53	1	Assig1
Error	14	error C2143: syntax error : missing ';' before '{'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	53	1	Assig1
Error	15	error C2447: '{' : missing function header (old-style formal list?)	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	53	1	Assig1
Error	16	error C2059: syntax error : ']'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	76	1	Assig1
Error	17	error C2143: syntax error : missing ';' before 'for'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	82	1	Assig1
Error	18	error C2065: 'aaFlight' : undeclared identifier	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	82	1	Assig1
Error	19	error C2228: left of '.length' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	82	1	Assig1
Error	20	error C2065: 'aFlight' : undeclared identifier	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	83	1	Assig1
Error	21	error C2228: left of '.id' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	83	1	Assig1
Error	22	error C2065: 'aFlight' : undeclared identifier	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	85	1	Assig1
Error	23	error C2065: 'aFlight' : undeclared identifier	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	85	1	Assig1
Error	24	error C2146: syntax error : missing ')' before identifier 'Flights'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	92	1	Assig1
Error	25	error C2182: 'ListFlights' : illegal use of type 'void'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	92	1	Assig1
Error	26	error C2059: syntax error : ')'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	92	1	Assig1
Error	27	error C2143: syntax error : missing ';' before '{'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	92	1	Assig1
Error	28	error C2447: '{' : missing function header (old-style formal list?)	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	92	1	Assig1
Error	29	error C2039: 'aCarrier' : is not a member of 'FlightType'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	106	1	Assig1
Error	30	error C2228: left of '.capacity' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	106	1	Assig1
Error	31	error C2039: 'aCarrier' : is not a member of 'FlightType'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	106	1	Assig1
Error	32	error C2228: left of '.destination' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	106	1	Assig1
Error	33	error C2039: 'aCarrier' : is not a member of 'FlightType'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	107	1	Assig1
Error	34	error C2228: left of '.aTime' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	107	1	Assig1
Error	35	error C2228: left of '.departure' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	107	1	Assig1
Error	36	error C2039: 'aCarrier' : is not a member of 'FlightType'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	107	1	Assig1
Error	37	error C2228: left of '.aTime' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	107	1	Assig1
Error	38	error C2228: left of '.arrival' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	107	1	Assig1
Error	39	error C2676: binary '[' : 'FlightType' does not define this operator or a conversion to a type acceptable to the predefined operator	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	127	1	Assig1
Error	40	error C2228: left of '.id' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	127	1	Assig1
Error	41	error C2676: binary '[' : 'FlightType' does not define this operator or a conversion to a type acceptable to the predefined operator	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	129	1	Assig1
Error	42	error C2228: left of '.id' must have class/struct/union	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	129	1	Assig1
Error	43	error C2660: 'PrintFlightData' : function does not take 1 arguments	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	129	1	Assig1
Error	44	error C2143: syntax error : missing ';' before '}'	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	130	1	Assig1
Error	45	error C2064: term does not evaluate to a function taking 0 arguments	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	146	1	Assig1
Error	46	error C2064: term does not evaluate to a function taking 0 arguments	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	152	1	Assig1
	47	IntelliSense: identifier "FlightsType" is undefined	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	28	1	Assig1
	48	IntelliSense: initialization with '{...}' expected for aggregate object	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	28	25	Assig1
	49	IntelliSense: identifier "FlightsType" is undefined	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	53	19	Assig1
	50	IntelliSense: identifier "FlightsType" is undefined	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	92	18	Assig1
	51	IntelliSense: variable "Flightno" is not a type name	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	92	41	Assig1
	52	IntelliSense: too many arguments in function call	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	98	18	Assig1
	53	IntelliSense: too few arguments in function call	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	146	18	Assig1
	54	IntelliSense: too few arguments in function call	d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp	152	17	Assig1


This post has been edited by busta5000: 30 September 2012 - 01:57 PM

Was This Post Helpful? 0
  • +
  • -

#12 jimblumberg  Icon User is offline

  • member icon


Reputation: 3993
  • View blog
  • Posts: 12,323
  • Joined: 25-December 09

Re: Printing several arrays by calling 1 array!

Posted 30 September 2012 - 01:27 PM

First you need to post the code that generated these warnings/errors. There are no templates in the code you provided in your last post.

Next what does this mean?

Quote

Sorry I always seem to change the code but I refused to use gentype since I felt it was unnececery

What is gentype?? If gentype is some kind of source format tool then it is indeed necessary. Proper indentation helps in many ways. For one with a proper indented source file it is much easier to spot missing or misplaced braces ({}). And it makes following the logic of the program much easier.

Next your snippets don't reflect as to what file contains them. Your error messages are useless if you don't provide the full code so we can see where the error occurs, the messages do tell this.

For example in your code you posted please point out the line this error is talking about:

Quote

Error 1 error C2143: syntax error : missing ';' before '<' d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp 90 1 Assig1

Where is line 90 in assign1.cpp?


Jim
Was This Post Helpful? 0
  • +
  • -

#13 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Re: Printing several arrays by calling 1 array!

Posted 30 September 2012 - 01:46 PM

Hey this is the new error log I do not think there is a gentype error in the new error log.
Gentype: Generic type that is part of unsortedlist that has a list of functions like delete, retrieve etc.
I have deleted them because I think its more difficult to call classes that refer to struct datatypes.
I actually explained every error in the code as a comment but I did not type the error line number within the code.
The errors are in syncronological order so every error I determine is part of the error I typed in the code as a comment.
I will edit the code & type the code number for every line.
There are over 54 errors its hard to write the number try to run the code in a compiler.
* Fixed error log I forgot to clear solution & recompile.

View Postjimblumberg, on 30 September 2012 - 01:27 PM, said:

First you need to post the code that generated these warnings/errors. There are no templates in the code you provided in your last post.

Next what does this mean?

Quote

Sorry I always seem to change the code but I refused to use gentype since I felt it was unnececery

What is gentype?? If gentype is some kind of source format tool then it is indeed necessary. Proper indentation helps in many ways. For one with a proper indented source file it is much easier to spot missing or misplaced braces ({}). And it makes following the logic of the program much easier.

Next your snippets don't reflect as to what file contains them. Your error messages are useless if you don't provide the full code so we can see where the error occurs, the messages do tell this.

For example in your code you posted please point out the line this error is talking about:

Quote

Error 1 error C2143: syntax error : missing ';' before '<' d:\courses\csc301\csc301_assig1\csc301_assig1\assig1\assig1.cpp 90 1 Assig1

Where is line 90 in assign1.cpp?


Jim

This post has been edited by busta5000: 30 September 2012 - 01:55 PM

Was This Post Helpful? 0
  • +
  • -

#14 jimblumberg  Icon User is offline

  • member icon


Reputation: 3993
  • View blog
  • Posts: 12,323
  • Joined: 25-December 09

Re: Printing several arrays by calling 1 array!

Posted 30 September 2012 - 01:50 PM

I would prefer if you posted the actual code along with the actual complete error messages.

Jim
Was This Post Helpful? 0
  • +
  • -

#15 busta5000  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: -7
  • View blog
  • Posts: 147
  • Joined: 08-March 08

Re: Printing several arrays by calling 1 array!

Posted 30 September 2012 - 02:13 PM

This is the actual code the problem with dreamincode is the code snippet is so small that you can't read properly so this is the full code using IDEONE website for code pasteing.

Note IDEONE has running code it has an error log that shows the erros better than writing them seperatly not knowing the lines
Complete code
http://ideone.com/0DJrd

View Postjimblumberg, on 30 September 2012 - 01:50 PM, said:

I would prefer if you posted the actual code along with the actual complete error messages.

Jim

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3