c++ - Split string into string and int -


i trying use sscanf(inputcmd, "%s%d", cmd, value); convert string inputcmd string cmd, , int value in arduino sketch. isn't working, apparently variables wrong type (string, instead of char*)

inputcmd in format foo90, , neither length of number or string can assumed constant. best way separate 2 parts of inputcmd , store them in 2 variables? cmd should foo, , value should 90.

thanks.

besides problem string versus char*, scanf format "%s" reads space-delimited string. if there's no space between string , number can't use sscanf.

as possible solution can attempt substring of each part of input string, , number-part convert int.

to find out length of first substring (which should put cmd) , starting position of number, need iterate on characters of string until find non-alphabetic character.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -