|
Prev: How to impliment searching the definition of a c/c++ function in a c/c++ source file
Next: encapsulating related utility functions
From: Ryan on 21 Jun 2008 07:27 I am inputing a year value and I want to create two variables, one only taking the first two digits of the year and the second taking the last two digits of the year. So, for example, if I input year = 1999, I want to assign the first variable the value 19 and the second variable 99. How do I do this? Thanks -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Oncaphillis on 21 Jun 2008 09:31 Ryan wrote: > I am inputing a year value and I want to create two variables, one > only taking the first two digits of the year and the second taking the > last two digits of the year. > > So, for example, if I input year = 1999, I want to assign the first > variable the value 19 and the second variable 99. > int year = 1999; // e.g int a = year / 100; // will be 19 int b = year % 100; // will be 99 O. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Daniel T. on 21 Jun 2008 09:32
Ryan <rwesslen(a)gmail.com> wrote: > I am inputing a year value and I want to create two variables, one > only taking the first two digits of the year and the second taking the > last two digits of the year. > > So, for example, if I input year = 1999, I want to assign the first > variable the value 19 and the second variable 99. > > How do I do this? What have you been taught about the language so far? Have you made any attempt at all of solving it yourself? If so, post what you have and you will get help. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |