Reputation: 1
If a have a string of character values, lets say
char charstring[k] = "word";
How would I convert the values of that string into a new string of the same length that holds the decimal values of the character string? There is no need to print out the conversion, I merely need a new string with decimal values.
Upvotes: 0
Views: 107
Reputation: 872
You already have:
#include <stdio.h>
int main(){
char s[] = "word";
char i;
for(i=0; s[i]; i++){
printf("%d or $%x\n", s[i], s[i]);
}
}
Upvotes: 1
Reputation: 1761
If you have
char charstring[] = "word";
then the string of the same length that holds the decimal values of the character string is charstring
. (Every character is stored internally as a number already.)
Upvotes: 1