Imed Jaberi 28908902ce
Improve the questions sub-folders names (#8850)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
2022-04-19 12:04:56 +08:00

1.7 KiB

C-printf Parser hard #template-literal

by Pig Fang @g-plane

Take the Challenge    日本語

There is a function in C language: printf. This function allows us to print something with formatting. Like this:

printf("The result is %d.", 42);

This challenge requires you to parse the input string and extract the format placeholders like %d and %f. For example, if the input string is "The result is %d.", the parsed result is a tuple ['dec'].

Here is the mapping:

type ControlsMap = {
  c: 'char',
  s: 'string',
  d: 'dec',
  o: 'oct',
  h: 'hex',
  f: 'float',
  p: 'pointer',
}

Back Share your Solutions Check out Solutions