I have an exercise to make the user type a word and it is transformed by their corresponding numbers from the ASCII table.
EXAMPLE : sara
would print 115 97 114 97
this is the code:
NOTE: I put a fixed value in the vector just for testing. The result of this is causing two problems:
-
At the time of rendering values, the first value (type prints
ara
and notsara
) -
And also prints odd numbers like -14
{ int i; char texto[15] ; printf("digite uma palavra"); gets(texto); fflush(stdin); scanf ("%c",texto); for (i=0; i<15; i++) { printf("Valor do elemento %d da string = %d\n",i, texto[i]); } getch(); }