How to convert a string into an integer in keil c?
Answer: sscanf can be used, just like sprintf converts an integer into a string and outputs it, and vice versa (scanf and printf in KEILC determine the input and output mode through the serial port of a single chip microcomputer, and are generally not used in practice unless modified). Let me give you an example: unsigned charstring [5] = {'1234'}; Unsigned integer n; sscanf(string,' %u ',& ampn); //string is a string, %u is a format control string and u is an unsigned decimal number. N is the address of the variable n. printf ('%d\n', n); //You can output the observed values in the KEIL C development environment. You can put some of the above code in HELLO. Write c program with KEIL C to observe and verify it. About the format control string (i.e., "%u", etc. ), you can check the related information of KEIL C, which is slightly different from the C language of PC. It can be converted into octal, 16, int, long and other data according to different requirements, and there are twenty related symbols, so I won't elaborate here.