0
  printf("Please enter the start date of your trip Month/Day/Year seperated by a space:");
      scanf("%d %d %d", &month, &day, &year);
      checkC = error_date(month,day,year);
      if (checkC == 2)
        {
          travel_month[i][0] == month;
          travel_day[i][0] == day;
          travel_year[i][0] == year;
        }
      else
        while (checkC==1)
          {
            printf("Please enter the start date of your trip Month/Day/Year seperated by a space:");
            scanf("%d %d %d", &month, &day, &year);
            checkC= error_date(month,day,year);
          }
  for (row = 0; row < trip_num; row++)
    {
      for (col=0; col < DEST; col++)
       printf("Trip#:%d %d/%d/%d\n", row+1, travel_month[row][col], travel_day[row][col], travel_year[row][col]);
    }

  return 0;
}



int error_date(int month, int day, int year)
{
  int checkC;
  if ( ((month > 0) && (month <= 12)) &&  ((day > 0) && (day <= 31)) && ((year> 2000) && (year < 2050)) )
    {
      checkC = 2;
      return checkC;
    }
  else
    {
      printf("Invalid date please re-enter date\n");
      checkC = 1;
      return checkC;
    }
}

Am I loading the month/day/year wrong, I keep getting weird integers when I'm printing out the array.

1 Answer 1

3

You need to use single equals sign for assignment:

      travel_month[i][0] == month;
      travel_day[i][0] == day;
      travel_year[i][0] == year;

should be

      travel_month[i][0] = month;
      travel_day[i][0] = day;
      travel_year[i][0] = year;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.