#include <avr/io.h>
#include <stdio.h>
#include <string.h>
#include "vorwahl.h"
int main() {
const char*n="037153136521"; // Telefonnummer zum Test
//Annahme: Standort Deutschland 2020
char c[8]="49"; // Deutschland
char o[8]="371"; // Chemnitz
char l;
if (*n=='+' || *n=='0' && n[1]=='0') {
l=Vorwahl::len_intl(n+=(*n=='+'?1:2));
if (l>7) l=0; // Fehler!
memcpy(c,n,l); c[l]=0;
printf("+%s ",c);
n+=l;
goto vw;
}else if (*n=='0') {
printf("0"); ++n;
vw:
if (!strcmp(c,"49")) l=Vorwahl::len_de(n);
else if (!strcmp(c,"43")) l=Vorwahl::len_at(n);
else l=0;
if (l>7) l=0; // Fehler!
memcpy(o,n,l); o[l]=0;
if (l) printf("%s ",o);
n+=l;
}
printf("%s\n",n); // restliche Telefonnummer
}
Detected encoding: ASCII (7 bit) | 2
|