473,388 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

dynamic array function

i try to make a function for dynamic array but have some problem with pointer parameter in my function.

have expression syntax error in line (68,21)

please help me and reply as soon as possible because I have to submit this coding tomorrow.

thank you so much.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  #include <conio>
  3.  
  4.  
  5.  const int listSize=2;
  6.  const int noOfEmployee=2;
  7.  const int noOfSalary=1;
  8.  
  9.  struct employeeInfo
  10.  {
  11.      char name[50], address[100],noPhone[50];
  12.    int age,ICnum;
  13.    int**employeeSalary;
  14.    void printSalary(employeeInfo Data[],int listSize,int **employeeSalary,int noOfEmployee,int noOfSalary);
  15.    //float salary,totalSalary,totalOT,hour;
  16.  };
  17.  
  18.  void getData (employeeInfo Data[],int listSize);
  19.  //void total (employeeInfo Data[],int listSize);
  20.  void printReport (employeeInfo Data[],int listSize);
  21.  void printSalary(employeeInfo Data[],int listSize,int **employeeSalary,int noOfEmployee,int noOfSalary);
  22.  
  23.  int main()
  24.  {
  25.  
  26.    textcolor(13);
  27.    textbackground(BLUE);
  28.    cprintf("                                                  ");cout<<"\n";
  29.    cprintf("      **********************************          ");cout<<"\n";
  30.    cprintf("      *                                *          ");cout<<"\n";
  31.    cprintf("      * PREPARED BY : DIANA & FARAH    *          ");cout<<"\n";
  32.    cprintf("      *                                *          ");cout<<"\n";
  33.    cprintf("      *                                *          ");cout<<"\n";
  34.    cprintf("      * CLASS GROUP : CSD2S4           *          ");cout<<"\n";
  35.    cprintf("      *                                *          ");cout<<"\n";
  36.    cprintf("      * PROJECT 138 : EMPLOYEE         *          ");cout<<"\n";
  37.    cprintf("      *               MANAGEMENT       *          ");cout<<"\n";
  38.    cprintf("      *               SYSTEM           *          ");cout<<"\n";
  39.    cprintf("      *                                *          ");cout<<"\n";
  40.    cprintf("      *                                *          ");cout<<"\n";
  41.    cprintf("      * LECTURER    : EN MALIK BIN     *          ");cout<<"\n";
  42.    cprintf("      *               BIN MOHD RICK    *          ");cout<<"\n";
  43.    cprintf("      *                                *          ");cout<<"\n";
  44.    cprintf("      **********************************          ");cout<<"\n";
  45.    cprintf("                                                  ");cout<<"\n";
  46.    cout<<endl;
  47.    textcolor(11);
  48.    textbackground(YELLOW);
  49.  
  50.      employeeInfo employeeData[listSize];
  51.    getData(employeeData,listSize);
  52.    /*cout<<"ENTER YOUR LATEST SALARY"<<endl;
  53.    cin>>employeeData[listSize].salary;*/
  54.  
  55.    //total (employeeData salary);
  56.  
  57.     cout<<endl;
  58.    textcolor(11);
  59.    textbackground(YELLOW);
  60.    cout<<"_____________________________________________________________________________"<<endl;
  61.    cprintf("                            EMPLOYEE FORM                                   ");cout<<"\n";//company name
  62.    cprintf("                      EMPLOYEE MANAGEMENT SYSTEM                            ");cout<<"\n";//company name
  63.    cprintf("                      DISPLAY THE EMPLOYEE DATA                             ");cout<<"\n";//company name
  64.    cout<<"_____________________________________________________________________________"<<endl;
  65.  
  66.  
  67.    printReport (employeeData,listSize);
  68.    printSalary(int **employeeSalary,noOfEmployee, noOfSalary);
  69.  
  70.  
  71.     getch();
  72.    return 0;
  73.  }
  74.  
  75.  void getData (employeeInfo Data[],int listSize)
  76.  {
  77.      for(int i=0;i<listSize;i++)
  78.        {
  79.           cout<<"ENTER YOUR NAME :";
  80.          cin>>ws;
  81.          cin.getline(Data[i].name,50);
  82.          cout<<"YOUR AGE  :";
  83.          cin>>Data[i].age;
  84.          cout<<"YOUR PHONE NUMBER  :";
  85.          cin>>ws;
  86.          cin.getline(Data[i].noPhone,50);
  87.          cout<<"IC NUMBER :";
  88.          cin>>Data[i].ICnum;
  89.          cout<<"YOUR ADDRESS : ";
  90.          cin>>ws;
  91.          cin.getline(Data[i].address,100);
  92.       }
  93.  }
  94.  
  95.  /*void total(employeeInfo Data[],int listSize)
  96.  {
  97.  
  98.  
  99.   if (Data[listSize].hour==1)
  100.        Data[listSize].totalOT=3.0;
  101.    else if (Data[listSize].hour>1 && Data[listSize].hour<5)
  102.        Data[listSize].totalOT=5.0;
  103.    else
  104.        Data[listSize].totalOT=0.0;
  105.  
  106.   for(int j=0;j>listSize;j++)
  107.      {
  108.  
  109.        cout<<"over time"<<endl;
  110.         cin>>Data[listSize].hour;
  111.         Data[j].totalSalary=Data[j].salary+Data[j].totalOT;
  112.    }
  113.  
  114.   } */
  115.  
  116.  void printReport (employeeInfo Data[],int listSize)
  117. {
  118.  for (int i=0;i<listSize;i++)
  119.   {
  120.         cout<<"NAME          :"<<Data[i].name<<endl;
  121.       cout<<"AGE           :"<<Data[i].age<<endl;
  122.       cout<<"PHONE NUMBER  :"<<Data[i].noPhone<<endl;
  123.       cout<<"IC NUMBER     :"<<Data[i].ICnum<<endl;
  124.       cout<<"ADDRESS       :"<<Data[i].address<<endl;
  125.   }
  126.  
  127.  
  128. }
  129.  
  130.  void printSalary(int **employeeSalary,int noOfEmployee,int noOfSalary)
  131.  {
  132.          cout<<"# OF EMPLOYEE AND SALARY :";
  133.       cin>> noOfEmployee>> noOfSalary ;
  134.  
  135.       employeeSalary = new int *[noOfEmployee];
  136.  
  137.       for (int row=0;row<noOfEmployee;row++)
  138.           employeeSalary [row] = new int [noOfSalary];
  139.  
  140.       for (int row=0;row<noOfEmployee;row++)
  141.       {
  142.             for (int column=0;column<noOfSalary;column++)
  143.          {
  144.              cout<<"\nENTER EMPLOYEE NO."<<(row+1)<<"SALARY"<< (column+1)<<" : ";
  145.             cin>>employeeSalary[row][column];
  146.          }
  147.  
  148.       }
  149.      cout<<"\nEMPLOYEE YOU HAVE ENTERED: \n";
  150.       for (int row=0;row<noOfEmployee;row++)
  151.       {
  152.           for (int column=0;column<noOfSalary;column++)
  153.          {
  154.              cout<<employeeSalary[row][column]<<"   ";
  155.          }
  156.          cout<<endl;
  157.       }
  158.  }
Apr 6 '10 #1
4 2054
newb16
687 512MB
int** is a bit off there
Apr 6 '10 #2
jkmyoung
2,057 Expert 2GB
You don't need to declare the type when calling the function; just pass the variables in.
Apr 6 '10 #3
can you give an example? i don't quiet understand.

thank you.
Apr 6 '10 #4
jkmyoung
2,057 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. int main(){
  2.    int i = 3;
  3.    int j = 4;
  4.    functionZ(int i, int j); // WRONG
  5.    functionZ(i,j); // Correct!
  6. }
  7.  
  8. void functionZ(int i, int j){
  9.   System.out.println("i"+i+" j"+j);
  10. }
  11.  
Apr 6 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Vannela | last post by:
How can i achieve the dynamic arrays concept in C#? I have used the ArrayLists of C# but in few cases it is failing like when i pass these dynamic arrays a arguments to functions b'coz in those...
6
by: Vasileios Zografos | last post by:
Hello, I have a function that generates some values (e.g. vertices in 2d space) the number of which I dont know. So, it could generate 20 vertices, 100 vertices, or even 1 vertex. void...
4
by: Scott Lyons | last post by:
Hey all, Can someone help me figure out how to pass a dynamic array into a function? Its been giving me some trouble, and my textbook of course doesnt cover the issue. Its probably something...
8
by: Peter B. Steiger | last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C is a simple word game that involves stringing together random lists of words. In the Pascal version the whole array was...
6
by: Materialised | last post by:
Hi Everyone, I apologise if this is covered in the FAQ, I did look, but nothing actually stood out to me as being relative to my subject. I want to create a 2 dimensional array, a 'array of...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
13
by: kwikius | last post by:
Does anyone know what a C99 dynamic array is, and if it will be useable in C++? regards Andy Little
1
by: lumumba401 | last post by:
Hello everybody, i am asking about how to define a bidimensional dynamic array as a global variable to use as incoming variable in a function Let us see , for example in a part of a programm...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
1
by: jmartmem | last post by:
Greetings, I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot. I have a form with a series of dynamic dependent list boxes....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.