1st off, Im new to C++ programming.
I created a function to calculate garage parking charges.
I keep getting this last error:
HourFee.cpp(65) : error C2065: 'ROW_SIZE' : undeclared identifier

this is my error ---> ***int vehicleInfo[ROW_SIZE][COLUMN_SIZE];***

void calculateCharges()
	{
		int x;
		int r;
		for (x=1; x<=10; x++)
		const int ROW_SIZE = 10;
		const int COLUMN_SIZE = 2;
		int vehicleInfo[ROW_SIZE][COLUMN_SIZE];
		r= x - 1;
		if (vehicleInfo[r][1] < 3.0)
			double cost = 2.00;
		if (vehicleInfo[r][1] > 18.0)
			double cost = 10.00;
		else
			
		for (double charge = 2.50; charge < 10.00; charge = charge + .05)
			{
			int time = 3;
			if (vehicleInfo[r][1] < time + 1)
			double cost = charge;
			else time = time + 1;
			}

			const int ARRAY_SIZE = 10;
			double costArray[ARRAY_SIZE];
			double cost = costArray [r];
			double total=0;
			cost += total;
	}

1st off, Im new to C++ programming.
I created a function to calculate garage parking charges.
I keep getting this last error:
HourFee.cpp(65) : error C2065: 'ROW_SIZE' : undeclared identifier

this is my error ---> ***int vehicleInfo[ROW_SIZE][COLUMN_SIZE];***

You have a brackets problem here:

for (x=1; x<=10; x++)
const int ROW_SIZE = 10;
const int COLUMN_SIZE = 2;
int vehicleInfo[ROW_SIZE][COLUMN_SIZE];

Adding brackets, the above code is interpreted as follows by the compiler:

for (x=1; x<=10; x++)
{
     const int ROW_SIZE = 10;
}
const int COLUMN_SIZE = 2;
int vehicleInfo[ROW_SIZE][COLUMN_SIZE];

ROW_SIZE is only "in scope" inside those brackets. The variable defined in line 3 is destroyed after the bracket in line 4. By the time you hit line 6, the compiler has no idea what you mean by ROW_SIZE.

What is the for-loop in line 1 supposed to accomplish? You need to decide what you want to have inside that for-loop and what you do not. You'll delineate that code with opening and closing brackets. No variables that you define for the first time INSIDE those brackets will be available to you in code that is OUTSIDE of those brackets.

I understand what you wrote about the brackets. But (and I read thru it at least 10 times) I dont have brackets there. Im lost. Should I add brackets? As I look at it, I see there should be a set of brackets after the "for" statement and close after the total statement to loop it.
OK lemmie start this again. Ive been working on this off n on for thr e last 2 wks - in the last 18 hrs its been minus 6 hrs of sleep. So Im a bit loopy myself. Ive typed 4 programs. It runs ok to a point then I hit the wall.
I figure if I can get the functions to compile, I can put them in the main block without toooo much headache - easier said than done.
I have to use a 2 dimensional array to store the information for the car and hours. Then I have to calculate the charges (in a function). I want to store the charges in a 1 dimensional array. I want this whole thing to loop 10 times (10 cars) while lastly totalling up the hours and charges into variables. THEN print the header, (function of the) array of the car #, hours and the array of the cost. The totals print on the bottom.

This is the farthest Ive gotten. I used a cout to see if it has stored the right info. It stores the right car# and hours, but I keep getting 2 for the cost (because I initialized it with 2.00). Oh...and it will only loop one time. I changed it around a few times. The other programs I wrote would loop and print the right car #, but wouldnt give me the right hours.
When I get this right, Ill move on to printing it out correctly and the totals.
ANY help is greatly appreciated.

#include <iostream>
#include <cmath>
using namespace std;

double enterHoursParked(int);
double calculateCharges (double);

int main()
{
	
		{
		int x=0;
			{
			enterHoursParked(x);
			}
		}

}

//Function to capture hours for each car parked
double enterHoursParked (int car)
{
	double cost=2.00;
	int x=0;
	double hours=0;	
	//Store car number and hours parked fm input
		for (x=1; x<=10; x++)
		{
	cout<<"Enter the total amount of hours car # "<< x <<" was parked in the garage (ex: 2.5)   ";
	double hours;
	cin>>hours;
	int y=0;
	int x=1;
	y=x-1;
	const int ROW_SIZE = 10;
	const int COLUMN_SIZE = 2;
	double vehicleInfo[ROW_SIZE][COLUMN_SIZE];
	vehicleInfo[y][1]=hours;
	vehicleInfo[y][0]=x;
	cout<<vehicleInfo[y][0]<<"    "<<hours<<endl;
	
	double calculateCharges (double hours);
	cout<<cost<<endl;
	return hours;
}

}

void calculateCharges()	
	{
		int x;
		int r;
		{
		for (x=1; x<=10; x++)
			{const int ROW_SIZE = 10;
			const int COLUMN_SIZE = 2;
			int vehicleInfo[ROW_SIZE][COLUMN_SIZE];
		r= x - 1;
		if (vehicleInfo[r][1] < 3.0)
			double cost = 2.00;
		if (vehicleInfo[r][1] > 18.0)
			double cost = 10.00;
		else
			
		for (double charge = 2.50; charge < 10.00; charge = charge + .05)
			{
			int time = 3;
			if (vehicleInfo[r][1] < time + 1)
			double cost = charge;
			else time = time + 1;
			}

			const int ARRAY_SIZE = 10;
			double costArray[ARRAY_SIZE];
			double cost = costArray [r];
			double total=0;
			cost += total;
		}
		}
		}

You have a major problem regarding scope of variables in C/C++. Lookup and study information on that subject very closely. Even better is, if you make simple tests to really understand how variables (including arrays) get created and destroyed in a program.

Instead of pointing out the errors in the program, I thought to write a couple of functions trying to demonstrate you how the overall structure of your program might be.
There is no two-dimensional array involved but I hope you get some ideas that you can employ and make progress. So here it goes ...

// This many vehicles at max, you can redefine it to e.g. 
// 10 whenever you want, it won't break anything
const int Vehicles = 2;

// struct VehicleInfo withholds information needed 
// for a single vehicle
struct VehicleInfo 
{
	double HoursParked;
	double Cost;
};
// Function prototypes
void GetInformation(VehicleInfo Info[], const int Count);
void CalcCost(VehicleInfo & Info);
void DisplayTotals(VehicleInfo Info[], const int Count);

void GetInformation(VehicleInfo Info[], const int Count)
{
	// Get the user input (hours) for each
        // vehicle and calculate the cost

	for(int ii = 0; ii < Count; ++ii)
	{
		cout
			<< "Enter the total amount of hours car # "
			<< ii
			<<" was parked in the garage (ex: 2.5) ";

		// Store the value directly in the array
		cin >> Info[ii].HoursParked;

		// Calculate the cost for the current vehicle
		CalcCost(Info[ii]);
	}
}

void CalcCost(VehicleInfo & Info)
{
	// Calculates the cost for one vehicle
	// Note that the Info is passed in by reference
        // (VehicleInfo [B]&[/B] Info)
	// hence you can modify its content inside this function

	// Get a reference (double [B]&[/B]) to the 
        // current vehicle's Cost variable and use it, whatever you 
        // set 'cost' to be, the value ends up in the Info.Cost
	double & cost = Info.Cost;

	// Now calculate the cost based on your criteria
	if(3.0 > Info.HoursParked)
	{
		cost = 2.0;
	}
	else if(18.0 < Info.HoursParked)
	{
		cost = 10.0;
	}
	else
	{
		// Calculate the more complicated cost here ...

		// todo: calculate it

		// todo: Finally, store the cost ...

		// cost = 
	}
}

void DisplayTotals(VehicleInfo Info[], const int Count)
{
	// Loop over all vehicles and display the information

	double TotalCost  = 0;
	double TotalHours = 0;

	for(int ii = 0; ii < Count; ++ii)
	{
		cout
			<< "Car # "
			<< ii
			<<" Hours: "
			<< Info[ii].HoursParked
			<< " Cost: "
			<< Info[ii].Cost
			<< endl;

		// Add to the grand total ...
		TotalCost += Info[ii].Cost;
		TotalHours += Info[ii].HoursParked;
	}

	// todo: display the grand total

	// cout << 
}


int main()
{
	// The one and only array of VehicleInfo structures,
	// initialized to empty
	VehicleInfo Info[Vehicles] = {0};

	// Get the information and calculate the costs,
	// pass in the array and the count of elements in it
	GetInformation(Info, Vehicles);
	
	// Display the information,
	// pass in the array and the count of elements in it
	DisplayTotals(Info, Vehicles);

	// Done ...
	return 0;
}

I understand what you wrote about the brackets. But (and I read thru it at least 10 times) I dont have brackets there. Im lost. Should I add brackets? As I look at it, I see there should be a set of brackets after the "for" statement and close after the total statement to loop it.
OK lemmie start this again. Ive been working on this off n on for thr e last 2 wks - in the last 18 hrs its been minus 6 hrs of sleep. So Im a bit loopy myself. Ive typed 4 programs. It runs ok to a point then I hit the wall.
I figure if I can get the functions to compile, I can put them in the main block without toooo much headache - easier said than done.
I have to use a 2 dimensional array to store the information for the car and hours. Then I have to calculate the charges (in a function). I want to store the charges in a 1 dimensional array. I want this whole thing to loop 10 times (10 cars) while lastly totalling up the hours and charges into variables. THEN print the header, (function of the) array of the car #, hours and the array of the cost. The totals print on the bottom.

Okay, I could have and should have been a lot more clear about making my point about the brackets. Sorry. My point was this. Yes you did not add brackets. When you DO NOT add brackets, the compiler looks at the next statement AFTER the for loop declaration and decides that that one statement is the code that you want to execute ten times. It is the EQUIVALENT of adding brackets around that one line. Thus this code:

for (x=1; x<=10; x++)
     const int ROW_SIZE = 10;
const int COLUMN_SIZE = 2;
int vehicleInfo[ROW_SIZE][COLUMN_SIZE];

is equivalent to this code:

for (x=1; x<=10; x++)
{
     const int ROW_SIZE = 10;
}
const int COLUMN_SIZE = 2;
int vehicleInfo[ROW_SIZE][COLUMN_SIZE];

I added the brackets in an attempt to make it more obvious what code was being repeated in the for-loop and what wasn't, but it had the opposite effect and added to the confusion. Again, sorry. You can always put brackets in to specify what code is inside of the for loop and what is not. NOT putting brackets in tells the compiler, as I mentioned, that you want exactly ONE statement to be repeated in the for-loop. If you want more than one statement repeated, as it appears you did, you MUST put brackets in your program to tell the compiler what code you want repeated in the for-loop and what you do not. My point about "scope" was that, regardless of whether you use brackets or not, any variables that you declare (i.e. ROW_SIZE) in the code that is being repeated in the for-loop will not be available to you after the for-loop has been completed. That was the error the compiler was giving you.

Thank you VernDozier and mitrmkar. Both of your comments have been very very helpful. Ive corrected my bracket issues. I looked at mitrmkars suggestions but some of what you posted, I havent learned yet (struct and the use of &).
I seem to have most of the program completed. My problem lies with passing the array information from one function to another. I know that because everything prints out, but the hours and costs print garbage, but its the same exact garbage for each row.
I used: double calculateCharges(vehicleInfo) but then I get: function-style initializer appears to be a function definition. When I just put double inside, there are no errors but I get the same number for the hours and costs. Im still playing with it tho.

If you have a graphical debugger, i.e. one with a GUI, then use the debugger to step through your code one line at a time to realize how your code actually works. You can see/watch contents of the variables as you debug, I think that might prove helpful too.

I used: double calculateCharges(vehicleInfo) but then I get: function-style initializer appears to be a function definition. When I just put double inside, there are no errors but I get the same number for the hours and costs. Im still playing with it tho.

I assume you are referring to line 42 in the code from post 4:

double calculateCharges (double hours);

That is not a function call. That is a function declaration. You already have it in line 6. You probably want a function CALL here:

calculateCharges (hours);

This loses the return value. If you want to keep that return value and put it into the cost variable, do this:

cost = calculateCharges (hours);

hej TheOneNOnlyQ I have been working on a game database recently and ive gotten the same problem like your do you know what should I do
this my source code:

#include<iostream>#include<conio.h>#define max 1000//------------------------------------------------------------------------------   using namespace std;       int main()       { struct moto{char gra[10];char rodzaj[10];int rok_produkcji;};moto game[max];   clrscr();cout<<"Podaj liczbę Gier których dane chcesz wprowadzic:\n";int n;cin>>n;for(int i=0; i<n;i++) cout<<"\n\n Podaj nazwe "<<i+1<<"gry:";cin>>game.gra;cout<<"\n podaj rodzaj"<<i+1<<"gry:";cin>>game.rodzaj;cout<<"\n podaj rok produkcji" <<i+1<<"gry:";cin>>game.rok_produkcji; )cout<<"\n\n wybierz opcje:\n";cout<<"1. szukanie wedlug nazwy gry:\n";cout<<"2.Szukanie wedlug daty produkcji:\n";int opcja;cin>>opcja;switch(opcja){case 1:cout<<"Podaj nazwe gry:\n";char name[10];cin>>name;clrscr(); for(int i=0; i<n;++i)if(stremp(name,game.gra)==0)cout<< "/n/n" <<game.gra<<""<<game.rodzaj<<"\n rok produkcji"<<game.rok_produkcji; break;case 2:cout <<"podaj rok produkcji gier:\n";int rok;cin>>rok;clrscr();for (i=0; i<n;i++)if(rok==game.rok_produkcji)cout<<"n\n" << game.gra<<game <<rok_produkcji; break;default:cout<<"Podaj numer 1 lub 2";}getch();  return 0;)}          #include<iostream>
#include<conio.h>
#define max 1000
//------------------------------------------------------------------------------
using namespace std;
int main()
{


struct moto{
char gra[10];
char rodzaj[10];
int rok_produkcji;
};
moto game[max];


clrscr();
cout<<"Podaj liczbę Gier których dane chcesz wprowadzic:\n";
int n;
cin>>n;
for(int i=0; i<n;i++)


cout<<"\n\n Podaj nazwe "<<i+1<<"gry:";
cin>>game.gra;
cout<<"\n podaj rodzaj"<<i+1<<"gry:";
cin>>game.rodzaj;
cout<<"\n podaj rok produkcji" <<i+1<<"gry:";
cin>>game.rok_produkcji;
)
cout<<"\n\n wybierz opcje:\n";
cout<<"1. szukanie wedlug nazwy gry:\n";
cout<<"2.Szukanie wedlug daty produkcji:\n";
int opcja;
cin>>opcja;
switch(opcja)
{
case 1:cout<<"Podaj nazwe gry:\n";
char name[10];
cin>>name;
clrscr();
for(int i=0; i<n;++i)
if(stremp(name,game.gra)==0)
cout<< "/n/n" <<game.gra<<""<<
game.rodzaj
<<"\n rok produkcji"<<game.rok_produkcji;


break;
case 2:cout <<"podaj rok produkcji gier:\n";
int rok;
cin>>rok;
clrscr();
for (i=0; i<n;i++)
if(rok==game.rok_produkcji)
cout<<"n\n" << game.gra<<game <<
rok_produkcji;


break;
default:cout<<"Podaj numer 1 lub 2";
}
getch();
return 0;
)
}
Help with Code Tags   cplusplus Syntax (Toggle Plain Text)            #include<iostream>#include<conio.h>#define max 1000//------------------------------------------------------------------------------   using namespace std;       int main()       { struct moto{char gra[10];char rodzaj[10];int rok_produkcji;};moto game[max];   clrscr();cout<<"Podaj liczbę Gier których dane chcesz wprowadzic:\n";int n;cin>>n;for(int i=0; i<n;i++) cout<<"\n\n Podaj nazwe "<<i+1<<"gry:";cin>>game.gra;cout<<"\n podaj rodzaj"<<i+1<<"gry:";cin>>game.rodzaj;cout<<"\n podaj rok produkcji" <<i+1<<"gry:";cin>>game.rok_produkcji; )cout<<"\n\n wybierz opcje:\n";cout<<"1. szukanie wedlug nazwy gry:\n";cout<<"2.Szukanie wedlug daty produkcji:\n";int opcja;cin>>opcja;switch(opcja){case 1:cout<<"Podaj nazwe gry:\n";char name[10];cin>>name;clrscr(); for(int i=0; i<n;++i)if(stremp(name,game.gra)==0)cout<< "/n/n" <<game.gra<<""<<game.rodzaj<<"\n rok produkcji"<<game.rok_produkcji; break;case 2:cout <<"podaj rok produkcji gier:\n";int rok;cin>>rok;clrscr();for (i=0; i<n;i++)if(rok==game.rok_produkcji)cout<<"n\n" << game.gra<<game <<rok_produkcji; break;default:cout<<"Podaj numer 1 lub 2";}getch();  return 0;)}          #include<iostream>
#include<conio.h>
#define max 1000
//------------------------------------------------------------------------------
using namespace std;
int main()
{


struct moto{
char gra[10];
char rodzaj[10];
int rok_produkcji;
};
moto game[max];


clrscr();
cout<<"Podaj liczbę Gier których dane chcesz wprowadzic:\n";
int n;
cin>>n;
for(int i=0; i<n;i++)


cout<<"\n\n Podaj nazwe "<<i+1<<"gry:";
cin>>game.gra;
cout<<"\n podaj rodzaj"<<i+1<<"gry:";
cin>>game.rodzaj;
cout<<"\n podaj rok produkcji" <<i+1<<"gry:";
cin>>game.rok_produkcji;
)
cout<<"\n\n wybierz opcje:\n";
cout<<"1. szukanie wedlug nazwy gry:\n";
cout<<"2.Szukanie wedlug daty produkcji:\n";
int opcja;
cin>>opcja;
switch(opcja)
{
case 1:cout<<"Podaj nazwe gry:\n";
char name[10];
cin>>name;
clrscr();
for(int i=0; i<n;++i)
if(stremp(name,game.gra)==0)
cout<< "/n/n" <<game.gra<<""<<
game.rodzaj
<<"\n rok produkcji"<<game.rok_produkcji;


break;
case 2:cout <<"podaj rok produkcji gier:\n";
int rok;
cin>>rok;
clrscr();
for (i=0; i<n;i++)
if(rok==game.rok_produkcji)
cout<<"n\n" << game.gra<<game <<
rok_produkcji;


break;
default:cout<<"Podaj numer 1 lub 2";
}
getch();
return 0;
)
}

The Eror messages are :

cpp(25) Undefined symbol "i"
cpp(30) expression Syntax
cpp(43)call to undefined function stremp
cpp(56) undefined symbol rok_produkcji
cpp(63) W8066 Unreachable code
cpp(63) Expresion Syntax
cpp(64) Statement missing;

and the error it shows me please visit my post

Good god what is crappy code you posted with has no line breaks ???? I was going to add code tags for you but they would be useless the way that code is formatted.

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.