| io/alph-num-sep-2.c - Et andet program der adskiller alfabetiske og numeriske afsnit i en tekst - læser fra en streng - virker ikke. | Lektion 13 - slide 24 : 32 Program 3 |
/* Does NOT work! Reports repeated MISMATCHes */
#include <stdio.h>
int main(void) {
char *str = "abc135def24681ghi3579";
char alph[25], numb[25];
int numres;
while (sscanf(str,"%[abcdefghijklmnopqrstuvwxyz]", alph) == 1){
numres = sscanf(str,"%[0123456789]", numb);
if (numres != 1)
printf("MISMATCH");
else
printf("Alphabetic: %s\n"
"Numeric: %s\n\n",
alph, numb);
}
return 0;
}