I would like to know how I could transform a character string to an ASCII value, such as "12ASD132 hello" in its ASCII values, and after that, if you have entered a character to skip an error
a greeting,
CodePudding user response:
To answer your first question: all C implementations I have ever seen store their characters in ASCII, so if your implementation is like that too, you can simply print character in the string as an integer:
#include <stdio.h>
int main() {
const char * str = "12ASD132 hello";
for (const char * p = str; *p; p ) {
printf("%d\n", *p);
}
}
CodePudding user response:
char *str = "12ASD132 hello";
printf("ch\tASCII\tASCII(HEX)\n");
while(*str)
{
printf("'%c'\t%d\t0xx\n", *str, *str, *str);
str ;
}
