mardi 4 août 2015

How to replace letters in a string with specific integer values?

I have a wriiten a C program that contains a char array 'long_string' that looks something like this.

 long_string[16] = "AHDAHDAHDAHDAHDA";

I wish to replace the letters in the string as follows: A-0, H-1, D-2.

Could somebody tell me how could I achieve this? I tried to look online but most of the cases show the conversion of letters to there ASCII values which is not what I need. THank you for your time in advance :)

Aucun commentaire:

Enregistrer un commentaire