dimanche 28 août 2016

How many times does a number/character occurs in a string literal?

No tokenization should be necessary. Consider the following string literal:

char* string = "12, 789, 1234";

The output for this specific string would be:

0, 2, 2, 1, 1, 0, 0, 1, 1, 1

This means that there were 0 zeros, 2 ones, 2 twos, 1 three, etc.

I understand that I could use the ASCII table but I was wondering if there was an easier way of doing it.

Aucun commentaire:

Enregistrer un commentaire