Skip to main content
added 14 characters in body
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

 

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);
 

These initializations are pointless in your code:

char* plates[1000] = {0};
int arr[10] = {0};

since you only access the elements of plates that you have assigned, always, from index 0 to n. And you never use arr. There are many practical cases when you have to initialize arrays to 0, but this is not one of them.

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);

These initializations are pointless in your code:

char* plates[1000] = {0};
int arr[10] = {0};

since you only access the elements of plates that you have assigned, always, from index 0 to n. And you never use arr. There are many practical cases when you have to initialize arrays to 0, but this is not one of them.

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

 

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);
 

These initializations are pointless in your code:

char* plates[1000] = {0};
int arr[10] = {0};

since you only access the elements of plates that you have assigned, always, from index 0 to n. And you never use arr. There are many practical cases when you have to initialize arrays to 0, but this is not one of them.

deleted 179 characters in body
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);

These initializations are pointless in your code:

char* plates[1000] = {0};
int arr[10] = {0};

since you only access the elements of plates that you have assigned, always, from index 0 to n. And you never use arr. There are many practical cases when you have to initialize arrays to 0, but this is not one of them.

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);

These initializations are pointless in your code:

char* plates[1000] = {0};
int arr[10] = {0};

since you only access the elements of plates that you have assigned, always, from index 0 to n. And you never use arr. There are many practical cases when you have to initialize arrays to 0, but this is not one of them.

deleted 179 characters in body
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);

These seem pointless statements:

char* plates[1000] = {0};
int arr[10] = {0};

You can just keep the declarations:

char* plates[1000];
int arr[10];

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);

These seem pointless statements:

char* plates[1000] = {0};
int arr[10] = {0};

You can just keep the declarations:

char* plates[1000];
int arr[10];

Your code would be a lot easier to understand if you renamed your variables. Don't do this just for others. Do it for yourself. If you look at this code a few months later, I bet you yourself will have trouble reading it. Rename the variables until the logic just flows. When the comments become pointless, you have succeeded (and then can drop the comments too).

In addition to what others already pointed out, I would just point out some things you could simplify.

Instead of these pointer arithmetics:

id = (*(a[0]+d) >= '0' && *(a[0]+d) <= '9') ? '0' : 'A';
count[*(a[i]+d) - id + 1]++;
aux[count[(*(a[i]+d) - id)]++] = a[i];
lsd_string_sort(&plates[0], n, PLATELENGTH);

You could write more intuitively:

id = a[0][d] >= '0' && a[0][d] <= '9' ? '0' : 'A';
count[a[i][d] - id + 1]++;
aux[count[(a[i][d] - id)]++] = a[i];
lsd_string_sort(plates, n, PLATELENGTH);
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391
Loading