Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Only error left Ideas?

Posted on 2011-02-21
4
550 Views
Last Modified: 2013-11-12
Airline code.cpp(481): fatal error C1075: end of file found before the left brace '{' at 'Airline code.cpp(11)' was matched

This is the only error I got left, anyone has any ideas on how to solve it?
0
Comment
Question by:IbanezRG
4 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 34941980
You have unterminated paired character (bracket, curly brace, or other) at line # 481. If you attach the code that would be easy to tell.
To solve it yourself just track the "{" and "}" and make sure you have closed every single one.

http://msdn.microsoft.com/en-us/library/4ybz0xh2%28v=vs.71%29.aspx
0
 
LVL 32

Accepted Solution

by:
phoffric earned 500 total points
ID: 34943597
I created a forms project - Pure MSIL Common Language RunTime Support (/clr:pure) and integrated your code into it. It builds and runs displaying an form that seems to work.
// WinCLR2.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace WinCLR2;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}

Open in new window


// Form1.h
//#pragma once
#include "stdafx.h"

#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <vcclr.h>

using namespace std;


namespace WinCLR2 {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
   
	const int SIZE = 20;

	/// <summary>
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	private:

		// Declare data members
		bool activeFlight;
		int numFirstClass;
		int numBusinessClass;

		// Declare managed arrays
		array <String^>^ passNameAr;
		array <String^>^ seatAr;
		array <String^>^ flightClassAr;

	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
         //Create new managed arrays from the heap
			passNameAr = gcnew array <String^>(SIZE);
			seatAr = gcnew array <String^>(SIZE);
			flightClassAr = gcnew array <String^>{"First","Business"};

			//Assign values to the arrays
			for (int i = 0; i < SIZE; i++)
				passNameAr[i] = "";
			seatAr[0] = "1A";
			seatAr[1] = "1B";
			seatAr[2] = "2A";
			seatAr[3] = "2B";
			seatAr[4] = "4A";
			seatAr[5] = "4B";
			seatAr[6] = "4C";
			seatAr[7] = "4D";
			seatAr[8] = "5A";
			seatAr[9] = "5B";
			seatAr[10] = "5C";
			seatAr[11] = "5D";
			seatAr[12] = "6A";
			seatAr[13] = "6B";
			seatAr[14] = "6C";
			seatAr[15] = "6D";
			seatAr[16] = "7A";
			seatAr[17] = "7B";
			seatAr[18] = "7C";
			seatAr[19] = "7D";

			activeFlight = true;
			numFirstClass = 0;
			numBusinessClass = 0;
			flightClassAr[0] = "First";
			flightClassAr[1] = "Business";

			cboFlightClass->DataSource = flightClassAr;
			cboSeatNumber->Items->Clear();

			for (int i = 0; i < 4; i++)
				cboSeatNumber->Items->Add(seatAr[i]);
			cboSeatNumber->SelectedIndex = 0;
			DisplayManifest();
			
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
   private: System::Windows::Forms::Label^  lblEntPassName;
	private: System::Windows::Forms::Label^  lblFlightClass;
	private: System::Windows::Forms::Label^  lblSeatNumber;


	private: System::Windows::Forms::TextBox^  txtPassengerName;
	private: System::Windows::Forms::ComboBox^  cboFlightClass;
	private: System::Windows::Forms::ComboBox^  cboSeatNumber;


	private: System::Windows::Forms::Button^  btnAddPassenger;
	private: System::Windows::Forms::Button^  btnCloseFlight;
	private: System::Windows::Forms::ListBox^  lbPlaneManifest;




	protected: 

	protected: 



	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
  			this->lblEntPassName = (gcnew System::Windows::Forms::Label());
			this->lblFlightClass = (gcnew System::Windows::Forms::Label());
			this->lblSeatNumber = (gcnew System::Windows::Forms::Label());
			this->txtPassengerName = (gcnew System::Windows::Forms::TextBox());
			this->cboFlightClass = (gcnew System::Windows::Forms::ComboBox());
			this->cboSeatNumber = (gcnew System::Windows::Forms::ComboBox());
			this->btnAddPassenger = (gcnew System::Windows::Forms::Button());
			this->btnCloseFlight = (gcnew System::Windows::Forms::Button());
			this->lbPlaneManifest = (gcnew System::Windows::Forms::ListBox());
         this->SuspendLayout();
         // 
			// lblEntPassName
			// 
			this->lblEntPassName->AutoSize = true;
			this->lblEntPassName->Location = System::Drawing::Point(49, 37);
			this->lblEntPassName->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
			this->lblEntPassName->Name = L"lblEntPassName";
			this->lblEntPassName->Size = System::Drawing::Size(162, 17);
			this->lblEntPassName->TabIndex = 0;
			this->lblEntPassName->Text = L"Enter Passengers Name";
			this->lblEntPassName->Click += gcnew System::EventHandler(this, &Form1::lblEntPassName_Click);
			// 
			// lblFlightClass
			// 
			this->lblFlightClass->AutoSize = true;
			this->lblFlightClass->Location = System::Drawing::Point(49, 96);
			this->lblFlightClass->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
			this->lblFlightClass->Name = L"lblFlightClass";
			this->lblFlightClass->Size = System::Drawing::Size(123, 17);
			this->lblFlightClass->TabIndex = 1;
			this->lblFlightClass->Text = L"Select Flight Class";
			this->lblFlightClass->Click += gcnew System::EventHandler(this, &Form1::lblflightClass_Click);
			// 
			// lblSeatNumber
			// 
			this->lblSeatNumber->AutoSize = true;
			this->lblSeatNumber->Location = System::Drawing::Point(379, 86);
			this->lblSeatNumber->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
			this->lblSeatNumber->Name = L"lblSeatNumber";
			this->lblSeatNumber->Size = System::Drawing::Size(82, 34);
			this->lblSeatNumber->TabIndex = 2;
			this->lblSeatNumber->Text = L"Select Seat\r\n      Number\r\n";
			this->lblSeatNumber->Click += gcnew System::EventHandler(this, &Form1::lblseatNumber_Click);
			// 
			// txtPassengerName
			// 
			this->txtPassengerName->Location = System::Drawing::Point(245, 27);
			this->txtPassengerName->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->txtPassengerName->Name = L"txtPassengerName";
			this->txtPassengerName->Size = System::Drawing::Size(309, 22);
			this->txtPassengerName->TabIndex = 3;
			this->txtPassengerName->TextChanged += gcnew System::EventHandler(this, &Form1::txtPassengerName_TextChanged);
			// 
			// cboFlightClass
			// 
			this->cboFlightClass->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->cboFlightClass->FormattingEnabled = true;
			this->cboFlightClass->Location = System::Drawing::Point(181, 92);
			this->cboFlightClass->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->cboFlightClass->Name = L"cboFlightClass";
			this->cboFlightClass->Size = System::Drawing::Size(172, 24);
			this->cboFlightClass->TabIndex = 4;
			this->cboFlightClass->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::cboFlightClass_SelectedIndexChanged);
			// 
			// cboSeatNumber
			// 
			this->cboSeatNumber->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->cboSeatNumber->FormattingEnabled = true;
			this->cboSeatNumber->Location = System::Drawing::Point(469, 92);
			this->cboSeatNumber->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->cboSeatNumber->Name = L"cboSeatNumber";
			this->cboSeatNumber->Size = System::Drawing::Size(83, 24);
			this->cboSeatNumber->TabIndex = 5;
			// 
			// btnAddPassenger
			// 
			this->btnAddPassenger->Location = System::Drawing::Point(39, 158);
			this->btnAddPassenger->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->btnAddPassenger->Name = L"btnAddPassenger";
			this->btnAddPassenger->Size = System::Drawing::Size(231, 28);
			this->btnAddPassenger->TabIndex = 6;
			this->btnAddPassenger->Text = L"Add Passenger";
			this->btnAddPassenger->UseVisualStyleBackColor = true;
			this->btnAddPassenger->Click += gcnew System::EventHandler(this, &Form1::btnAddPassenger_Click);
			// 
			// btnCloseFlight
			// 
			this->btnCloseFlight->Location = System::Drawing::Point(345, 158);
			this->btnCloseFlight->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->btnCloseFlight->Name = L"btnCloseFlight";
			this->btnCloseFlight->Size = System::Drawing::Size(237, 28);
			this->btnCloseFlight->TabIndex = 7;
			this->btnCloseFlight->Text = L"Close Flight";
			this->btnCloseFlight->UseVisualStyleBackColor = true;
			this->btnCloseFlight->Click += gcnew System::EventHandler(this, &Form1::btnCloseFlight_Click);
			// 
			// lbPlaneManifest
			// 
			this->lbPlaneManifest->FormattingEnabled = true;
			this->lbPlaneManifest->ItemHeight = 16;
			this->lbPlaneManifest->Location = System::Drawing::Point(39, 219);
			this->lbPlaneManifest->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->lbPlaneManifest->Name = L"lbPlaneManifest";
			this->lbPlaneManifest->Size = System::Drawing::Size(543, 388);
			this->lbPlaneManifest->TabIndex = 8;
			this->lbPlaneManifest->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::lbPlaneManifest_SelectedIndexChanged);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(629, 624);
			this->Controls->Add(this->lbPlaneManifest);
			this->Controls->Add(this->btnCloseFlight);
			this->Controls->Add(this->btnAddPassenger);
			this->Controls->Add(this->cboSeatNumber);
			this->Controls->Add(this->cboFlightClass);
			this->Controls->Add(this->txtPassengerName);
			this->Controls->Add(this->lblSeatNumber);
			this->Controls->Add(this->lblFlightClass);
			this->Controls->Add(this->lblEntPassName);
			this->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->Name = L"Form1";
			this->Text = L"Bluebird Airlines Flight Reservation System";
			this->ResumeLayout(false);
			this->PerformLayout();
      }
#pragma endregion
	private: System::Void lblseatNumber_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
			 }
	private: System::Void lblflightClass_Click(System::Object^  sender, System::EventArgs^  e)
			 {
			 }
		 
	private: System::Void lblEntPassName_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
			 }
	private: System::Void txtPassengerName_TextChanged(System::Object^  sender, System::EventArgs^  e) 
			 {
		     }
	private: System::Void btnAddPassenger_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
				 String^ errMess;
				 String^ passName = txtPassengerName->Text;
				 String^ flightClass = cboFlightClass->Text;
				 String^ seatNum = cboSeatNumber->Text;

				 if (passName == "")
				 {
					 errMess = "Must enter passenger name";
					 MessageBox::Show(errMess, "E R R O R");
					 txtPassengerName->Focus();
					 return;
				 }

				 int i = 0;
				 int seatIdx = 0;

				 for (i = 0; i < SIZE; i++)
					 if (seatNum == seatAr[i])
					 {
						 seatIdx = i;
						 break;
					 }

					 AssignSeat (passName, flightClass, seatIdx);
					 DisplayManifest();
					 PopulateSeatCombo();

			 }
    private: System::Void btnCloseFlight_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
				 if (activeFlight)
				 {
					 DisplayManifest();
					 DisplayPassengerList();
					 btnCloseFlight->Text = "Start a New Flight";
					 activeFlight = false;
					 btnCloseFlight->Focus();
					 btnAddPassenger->Enabled = false;
				 }
				 else
				 {
					 btnCloseFlight->Text = "Close Flight";
					 btnAddPassenger->Enabled = true;

					 for (int i = 0; i < SIZE; i++)
						 passNameAr[i] = "";

					 Array::Sort(seatAr);
					 cboSeatNumber->Items->Clear();

					 for (int i = 0; i < 4; i++)
						 cboSeatNumber->Items->Add(seatAr[i]);

					 cboSeatNumber->SelectedIndex = 0;
					 numFirstClass = 0;
					 numBusinessClass = 0;
					 DisplayManifest();
					 activeFlight = true;
					 txtPassengerName->Focus();
				 }
			 }

    private: System::Void cboFlightClass_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) 
			 {
				 int i;
				 cboSeatNumber->Items->Clear();
				 if (cboFlightClass->Text == "First")
				 {
					 for (i = 0; i < 4; i++)
						 if (passNameAr[i] == "")
							 cboSeatNumber->Items->Add(seatAr[i]);
				 }
				 else
				 {
					 for (i = 4; i < SIZE; i++)
						 if (passNameAr[i] == "")
							 cboSeatNumber->Items->Add(seatAr[i]);
				 }
				 if (cboSeatNumber->Items->Count > 0)
					 cboSeatNumber->SelectedIndex = 0;

			 }

    private: System::Void lbPlaneManifest_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) 
			 {
			 }
	private: void DisplayPassengerList()
			 {
				 std::ofstream outFile;

				 outFile.open("PlaneManifest.txt");
				 outFile << "    P L A N E    M A N I F E S T\n";
				 outFile << " Seat           Passenger Name\n";

				 for (int i = 0; i < SIZE; i++)
				 {
					 String ^passS = passNameAr[i]; // convert passNameAr to char*
					 pin_ptr<const wchar_t> wchP = PtrToStringChars(passS); // Pin memory so GC can't move it 
																			// while native function is called
					 size_t convertedCharsP = 0; // convert to char*
					 size_t sizeInBytesP = ((passS->Length + 1) * 2);
					 errno_t errP = 0;
					 char    *pass = (char *)malloc(sizeInBytesP);
					 errP = wcstombs_s(&convertedCharsP, pass, sizeInBytesP, wchP, sizeInBytesP);


					 String ^seatS = seatAr[i]; // convert passNameAr to char*
					 pin_ptr<const wchar_t> wchS = PtrToStringChars(seatS); // Pin memory so GC can't move it 
																			// while native function is called
					 size_t convertedCharsS = 0; // convert to char*
					 size_t sizeInBytesS = ((seatS->Length + 1) * 2);
					 errno_t errS = 0;
					 char    *seat = (char *)malloc(sizeInBytesS);
					 errS = wcstombs_s(&convertedCharsS, seat, sizeInBytesS, wchS, sizeInBytesS);
					 outFile << "  " << seat << "\t\t" << pass << "\n";
					 //outFile << "  " << seatAr[i]->ToCharArray() << "\t\t" << passNameAr[i]->ToCharArray() << "\n";
				 }


				 Array::Sort(passNameAr, seatAr);
				 String^ str = String::Format("     First Class; (0)    Business Class: (1)", numFirstClass, numBusinessClass);
								              //"     First Class: " + numFirstClass + "   Business Class: " + numBusinessClass + "\n";

				 lbPlaneManifest->Items->Add(" N U M B E R   O F   P A S S E N G E R S");
				 lbPlaneManifest->Items->Add(str);
				 lbPlaneManifest->Items->Add("");

				 outFile << "\n\n  N U M B E R   O F   P A S S E N G E R S\n";
					 pin_ptr<const wchar_t> wch = PtrToStringChars(str);   // Pin memory so GC can't move it while native function is called
					 size_t convertedChars = 0;                            // Convert to Char
					 size_t sizeInBytes = ((str->Length + 1) * 2);
					 errno_t err = 0;
					 char    *ch = (char *)malloc(sizeInBytes);

				 err = wcstombs_s(&convertedChars, ch, sizeInBytes, wch, sizeInBytes);
				 outFile << ch << "\n" << "\n" << "\n";  // outFile << str->ToCharArray() << "\n" << "\n" << "\n";


				 lbPlaneManifest->Items->Add("         P A S S E N G E R   L I S T");
				 lbPlaneManifest->Items->Add("   Passenger Name                     seat");
				 outFile << "         P A S S E N G E R   L I S T\n";
				 outFile << "   Passenger Name                     seat\n";
				 
				 for (int i = 0; i < SIZE; i++)
				 {
				 if (passNameAr[i]->Length > 0)
				 {
					 str = String::Format("(0, -30)         (1)", passNameAr[i], seatAr[i]);
					 lbPlaneManifest->Items->Add(str);

					 pin_ptr<const wchar_t> wch = PtrToStringChars(str);   // Pin memory so GC can't move it while native function is called
					 size_t convertedChars = 0;                            // Convert to Char
					 size_t sizeInBytes = ((str->Length + 1) * 2);
					 errno_t err = 0;
					 char    *ch = (char *)malloc(sizeInBytes);

					 err = wcstombs_s(&convertedChars, ch, sizeInBytes, wch, sizeInBytes);
					 outFile << ch << "\n";  // outFile << str->ToCharArray() << "\n";

				 }
			 }
			 outFile.close();

		} 
	private: void DisplayManifest()
	    {
		    String^ str;
		    lbPlaneManifest->Items->Clear();
		    lbPlaneManifest->Items->Add("    P L A N E   M A N I F E S T");
		    lbPlaneManifest->Items->Add(" Seat          Passenger Name");
		    for (int i = 0; i < SIZE; i++)
		    {
			    str = "  " + seatAr[i] + "\t\t" + passNameAr[i];
			    lbPlaneManifest->Items->Add(str);
		    }
	    }
	private: void AssignSeat(String^ passName, String^ flightClass, int seatIdx)
		{
			passNameAr[seatIdx] = passName;

			if (flightClass == "First")
				numFirstClass++;
			else
				numBusinessClass++;

		}
	private: void PopulateSeatCombo()
		{
			int i;
			txtPassengerName->Text = "";
			flightClassAr = gcnew array<String^>(2);
			flightClassAr[0] = "First";
			flightClassAr[1] = "Business";
			cboFlightClass->DataSource = flightClassAr;
			cboFlightClass->SelectedIndex = 0;
			cboSeatNumber->Items->Clear();

			if (numFirstClass + numBusinessClass == 20)
			{
				btnCloseFlight->Focus();
				btnAddPassenger->Enabled = false;
				return;
			}

			txtPassengerName->Focus();

			if (numFirstClass < 4)
			{
				for (i = 0; i < 4; i++)
					if (passNameAr[i] == "")
						cboSeatNumber->Items->Add(seatAr[i]);
				
				if (numBusinessClass == 16)
				{
					flightClassAr = gcnew array<String^>(1);
					flightClassAr[0] = "First";
					cboFlightClass->DataSource = flightClassAr;
				}
			}
			else
			{
				flightClassAr = gcnew array<String^>(1);
				flightClassAr[0] = "Business";
				cboFlightClass->DataSource = flightClassAr;

				for (i = 4; i < SIZE; i++)
					if (passNameAr[i] == "")
						cboSeatNumber->Items->Add(seatAr[i]);
			}

			if (cboSeatNumber->Items->Count > 0)
				cboSeatNumber->SelectedIndex = 0;
		}
   };								  
}

Open in new window

0
 
LVL 11

Expert Comment

by:cup
ID: 34946447
The other possibilities are

1)  Mismatched quotes in strings - quite easy to spot these if you modify the text editor to show all strings in say magenta.
2) Unterminated comments (/* */ type or trailing \ in a comment).  These are quite easy to spot if you change the background of your comments to something like yellow.  It shows up all the comments straight away.
3) Mismatched () or {}.  If you put your cursor on a { or ( and press ctrl ],  The cursor will jump to the matching ) or }.  Press ctrl ] to jump back.
0
 

Author Closing Comment

by:IbanezRG
ID: 34946986
I started a new project and it worked, thanks a lot.
I have lots to learn.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Homework Help 5 95
Problem with SqlConnection 4 178
How do I save this device context as a .bmp or a picture of some kind? 2 64
c++, dynamic object by json 1 53
Introduction This article discusses the Chain of Responsibility pattern, explaining What it is;Why it is; andHow it is At the end of this article, I hope you will be able to describe the use and benefits of Chain of Responsibility.  Backgrou…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question