I am creating a class and I want to create a constructor that takes input as string in the form: yyyy-mm-dd hh:nn:ss (e.g. 2017-11-15 12:14:54). I would like to save the year, month, day, hours, minutes and seconds in individual variables (preferably of type int). That is, I want to save the first 4 characters of the string in one variable, the characters corresponding to mm in another variable, etc. I know it is possible to convert strings to int, but I do not know how to convert specific characters in the string to a variable. Any help would be very much appreciated.
Aucun commentaire:
Enregistrer un commentaire