简体   繁体   中英

converting a string to a simple one character value in C language

I'm writing a compiler with Flex and Bison using C langage and need to convert a character string to a one simple character. which functions should i use? i can't find it. forexample:

-string to integer we use : int i = atoi(yytext);
-string to float we use :   float f = atof(yytext);

If I understand your question, a character string with one value is just a character string of [0] so why not just do something like...

char new_char = char_string[0];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM