MNC/MCC as string?

Marcel Holtmann marcel at holtmann.org
Fri Jun 12 03:12:33 PDT 2009


Hi Aki,

> Anyway, here it is. Please test; seems to work for me on my N95.

+static void extract_mcc_mnc(const char *str, char *mcc, char *mnc)
 {
-       int num = 0;
-       unsigned int i;
-
        /* Three digit country code */
-       for (i = 0; i < 3; i++)
-               num = num * 10 + (int)(str[i] - '0');
-
-       *mcc = num;
-
-       num = 0;
+       strncpy(mcc, str, sizeof(mcc));
+       mcc[3] = '\0';

maybe I am blind, but how is this suppose to work. The sizeof(mmc) is 1
byte.

Regards

Marcel




More information about the ofono mailing list