#Sorting Strategey

4 messages · Page 1 of 1 (latest)

astral folio
#
/* Function that implements the sort utility.
   sep is the character used to separate fields within each line.
   field is the index of the field that will be used to sort lines.
   If field is -1, it indicates that the field argument was not passed. */
static void sort(char sep, int field)
{
  /* WRITE YOUR CODE HERE */
  int i;
  int j;
  for(i =0; i < ROWS; i++)
  {
      for(j=0; j < COLS; j++)
      {
          
      }
  }
  
  
}``` I have this code here for a sort function how can i use getLine function to fill up the information as seen on the img.
strong tapirBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

astral folio
#
/* Reads a line of characters from standard input and copies
   them into dest. Returns the number of characters written into 
   dest, including the terminating null character. The function
   stops copying characters if it encounters the newline character
   ('\n') or EOF (i.e., the line ends) or if lim-1 characters have been
   read (to allow space for a terminating null character). */
int csc225_getline(char dest[], int lim)
{
  int c = EOF;

  int i = 0;
  for (i; i < lim - 1; i++)
  {
    c = getchar();
    if (c == EOF || c == '\n')
      break;

    dest[i] = c;
  }

  if (c == '\n')
  {
    dest[i++] = c;
  }

  dest[i] = '\0';

  return i;
}``` This is the getLine function
strong tapirBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.