Closed Thread Icon

Topic awaiting preservation: C programming (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8556" title="Pages that link to Topic awaiting preservation: C programming (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: C programming <span class="small">(Page 1 of 1)</span>\

 
supreme_commander
Nervous Wreck (II) Inmate

From: QLD
Insane since: Mar 2003

posted posted 03-02-2003 23:48

Hi - i am relativly new to c programming but i was wondering if anyone could help me out
I have an unsigned int yearEnrolled = 2001

i need to be able to access or assigned the 4th digit in yearEnrolled (assuming that yearEnrolled can be changed at any time).

So i can use a switch statment to create a iD - eg if 4 digit is 0 =A, 1 = B etc.
i have tried all i know to be able to try and get the int to a str of char array so i can use just one digit but no luck.

Can anyone help please
Thanks

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-03-2003 02:14

The fourth digit from the left or the right? (the "2" or the "1" in "2001"?)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 03-03-2003 17:16

2001 % 10 will get you the last digit (the 1)
2001 / 1000 will get you the first. (the 2)



.:[ Never resist a perfect moment ]:.

« BackwardsOnwards »

Show Forum Drop Down Menu