- see the ASCII chart for what char values 0-15 represent
- since '"TO"' is a c-string, the "+" is not how strings are appended together
- since both comrx and '"TO"' are c-strings, "==" is not how they are compared (use strcmp())
consider the two approaches demonstrated in the code below to compare strings or extract the integer value from "comrx" that can more easily be compared
TO3 TO0 3
TO3 TO1 2
TO3 TO2 1
TO3 TO3 0
TO3 TO4 -1
TO3 TO5 -2
TO3 TO6 -3
TO3 TO7 -4
TO3 TO8 -5
TO3 TO9 -6
TO3 TO10 2
TO3 TO11 2
TO3 TO12 2
TO3 TO13 2
TO3 TO14 2
TO3 TO15 2
n = 3
#include <stdio.h>
#include <string.h>
int
main ()
{
const char *comrx = "TO3";
for (int i = 0; i <= 15; i++) {
char s [10];
sprintf (s, "TO%d", i);
printf (" %4s %4s %4d\n", comrx, s, strcmp (comrx, s));
}
int n;
sscanf (comrx, "TO%d", & n);
printf (" n = %d\n", n);
return 0;
}