Thread: Two dimensional arrays

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    5

    Two dimensional arrays

    Just a few q's for ya. Don't Have A Clue if this is right.
    Reading a file, using toupper and two dimensional arrays for this part of the program. This is what I have.
    section[i]=toupper(section[i]);
    for(i=0; i !=EOF; i++)
    {
    for(x=0; x !=EOF;xi++)
    {
    input_status=fscanf, "%s %s %ld %lf %c\n",&last[i], &first[i], &emp_id[i], &wg_hr_py[i][x], &section[i]);
    }
    }
    emp_counter=i;
    return(emp_counter);

    I have to sort my arrays. I have two dimentional arrays to sort and strings to sort. I am getting Alot of errors when I run this part of my program. I just can't figure it out.
    for(i = 0; i<emp_counter; i++)
    {
    for[j = 0; j<emp_counter; j++)
    {
    if(strcmp(last[j - 1] > last[j]))
    {
    strcmp(temp_last, last);
    strcpy(temp_last, last[j - 1]);
    strcpy(last[j - 1], last[j]);
    strcpy(last[j], temp_last);

    temp_emp_id = emp_id [j - 1];
    emp_id [j - 1] = emp_id [j];
    emp_id [j] = temp_emp_id;

    strcmp(temp_first, first);
    strcpy(temp_first, first[j - 1]);
    strcpy(first[j - 1], first[j]);
    strcpy(first[j], temp_first);

    temp_wage = wg_hr_py [j - 1][0];
    wg_hr_py [j - 1][0] = wg_hr_py [j][0];
    wg_hr_py [j][0] = temp_wage;

    temp_hours_worked = wg_hr_py [j - 1][1];
    wg_hr_py [j - 1][1] = wg_hr_py [j][1];
    wg_hr_py [j][1] = temp_hours_worked;

    temp_weekly_pay = wg_hr_py [j - 1][2];
    wg_hr_py [j - 1][2] = wg_hr_py [j][2];
    wg_hr_py [j][2] = temp_weekly_pay;

    strcpy(temp_section, section[j - 1];
    strcpy(section[j - 1], section[j]);
    strcpy(section[j], section);

    }
    }
    }
    Thanks alot


  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    input_status=fscanf, "%s %s %ld %lf %c\n",&last[i], &first[i], &emp_id[i], &wg_hr_py[i][x], §ion[i]);
    //Something missing here

    for[j = 0; j<emp_counter; j++)
    //Replace [ with a ( here

    {
    if(strcmp(last[j - 1] > last[j]))
    //Should be
    //if(strcmp(last[j - 1],last[j]) > 0)

    {
    strcmp(temp_last, last);
    //Take this line out

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 04:49 PM
  2. Dynamic two dimensional arrays
    By ThWolf in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 02:28 PM
  3. Two dimensional arrays
    By Masschino in forum C Programming
    Replies: 9
    Last Post: 05-18-2004, 08:17 PM
  4. dimensional arrays
    By ZakkWylde969 in forum C++ Programming
    Replies: 3
    Last Post: 08-04-2003, 04:49 PM
  5. two dimensional arrays
    By ssjnamek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 08:12 PM