normally im good at debugging code and fixing errors but im not that good with arrays or structures so sorry if im asking for alot of errors to be fixed for me but its not cuz im lazy im jus not good with arrays or structures sorry aight well id appreciate ur help thanx
#include <iostream.h>
#include <fstream.h>
struct jobInfo
{
short code;
long salary;
};
//function prototypes
void fillArray(ifstream, jobInfo ,short);
void searchAndDisplay(short, jobInfo[],short);
void main()
{
//declare and intilize varaible
short searchCode = 0;
//declare and initialize the array
jobinfo job[10];
for(int i = 0; i < 10; i++)
{
job[i].code = 0;
job[i].salary = 0.00;
}
//open file for input
ifstream infile;
infile.open("codes.dat",ios::in);
//verify that open was successful
if (!infile.fail())//open was successful
{
//fill arrays with data
fillArray(infile,jobInfo Job, 10);
//close file
infile.close();
//get a code
cout<<"enter the code (0 to stop)\n";
cin>>searchCode;
cin.ignore(100,'\n');
while (searchCode != 0)
{
//search the array for the code and display the salary
searchAndDisplay(searchCode, job, 10);
//get another code
cout<<"enter the code (0 to stop)\n";
cin>>searchCode;
cin.ignore(100,'\n');
}//end while
}
else
cout<<"error opening file\n";
//end if
}//end main function
void fillArray(ifstream inEmp, jobInfo ,short size)
{
//this function fills the arrays with data from a file
for(short x = 0; x < size; x = x+ 1)
{
//enter data from a file into arrays
inEmp >>employ[x].code;
inEmp.ignore(1);
inEmp>>employ[x].salary;
inEmp.ignore(1);
}//end for
}//end of fillArray function
void searchAndDisplay(short inputCode,jobInfo employ[],short size)
{
/*this function searches for the code in the array
if the code is in the array, the salary is displayed
if the code is not in the array, a message is displayed*/
short x = 0;
char found = 'F';
while (x<size && found == 'F')
{
if(employ[x].code == inputCode)//code is in the array
{
cout<<"Salary: "<<employ[x].salary<<"\n\n";
found = 'T';
}
else
//add 1 to counter variable
x = x+ 1 ;
//end if
}//end while
if(found == 'F')//code is not in the array
cout<<"The salary is not the available.\n\n";
//end if
}//end of searchAndDisplay function
//end of code
--------------------Configuration: array - Win32 Debug--------------------
Compiling...
array.cpp
C:\Windows\Desktop\c++\array.cpp(17) : error C2065: 'jobinfo' : undeclared identifier
C:\Windows\Desktop\c++\array.cpp(17) : error C2146: syntax error : missing ';' before identifier 'job'
C:\Windows\Desktop\c++\array.cpp(17) : error C2065: 'job' : undeclared identifier
C:\Windows\Desktop\c++\array.cpp(17) : error C2109: subscript requires array or pointer type
C:\Windows\Desktop\c++\array.cpp(21) : error C2109: subscript requires array or pointer type
C:\Windows\Desktop\c++\array.cpp(21) : error C2228: left of '.code' must have class/struct/union type
C:\Windows\Desktop\c++\array.cpp(22) : error C2109: subscript requires array or pointer type
C:\Windows\Desktop\c++\array.cpp(22) : error C2228: left of '.salary' must have class/struct/union type
C:\Windows\Desktop\c++\array.cpp(35) : error C2275: 'jobInfo' : illegal use of this type as an expression
C:\Windows\Desktop\c++\array.cpp(4) : see declaration of 'jobInfo'
C:\Windows\Desktop\c++\array.cpp(35) : error C2146: syntax error : missing ')' before identifier 'Job'
C:\Windows\Desktop\c++\array.cpp(35) : error C2059: syntax error : ')'
C:\Windows\Desktop\c++\array.cpp(62) : error C2065: 'employ' : undeclared identifier
C:\Windows\Desktop\c++\array.cpp(62) : error C2109: subscript requires array or pointer type
C:\Windows\Desktop\c++\array.cpp(62) : error C2228: left of '.code' must have class/struct/union type
C:\Windows\Desktop\c++\array.cpp(64) : error C2109: subscript requires array or pointer type
C:\Windows\Desktop\c++\array.cpp(64) : error C2228: left of '.salary' must have class/struct/union type
Error executing cl.exe.
array.obj - 16 error(s), 0 warning(s)