* Array-01. character conversion, array-01 character conversion
1/* 2 * Main. c 3 * E1-array-01. character conversion 4 * Created on: August 20, 2014 5 * Author: in the Boomkeeper 6 ****** section, *********** 7 */8 9 # include <stdio. h> 10 11 int main (void) {12 13 char str [80] = {-1}; 14 15 gets (str); 16 17 int I; 18 for (I = 0; I <80; I ++) {19 if (str [I]> = '0' & str [I] <= '9 ') 20 putchar (str [I]); 21} 22 putchar ('\ n'); 23 24 return 0; 25}
Question link:
Http://pat.zju.edu.cn/contests/basic-programming/%E6%95%B0%E7%BB%84-01
.
How to convert a string to an array
S. subString (0, 2 );
Extract the first two digits and load the substring into an array.
If the string is regular, for example, s = "23-3-4-2"
You can follow String [] str = s. split ("-");
In this way, the string can be split into character arrays "-".
C # convert string to hexadecimal Array
Use Convert. ToInt32 ("aa", 16 );
The converted int type is saved in the bytes array.