User Tools

Site Tools


Sidebar

projects

  • cci0 (due 20150128)
  • mms0 (due 20150204)
  • mbe0 (due 20150211)
  • mbe1 (due 20150311)
  • afn0 (due 20150318)
  • cbf0 (due 20150408)
  • EoCE - bottom of your Opus (due 20150514 by 4:30pm)
haas:spring2015:cprog:projects:eocehints

This is an old revision of the document!


EoCE Hints

An attempt at sharing some of the great questions I've received with everybody.

0x1: Octal

In argv[1] the number input is an array of characters but it needs conversion to a singular octal value. Why?

As argv[1] is an array of characters… if you give it 640, it'll actually be “640\0”, that is, ASCII character '6', followed by ASCII character '4', followed by ASCII character '0', followed by the NULL terminator.

'6' has a numeric value of 54 (decimal).

If you were to convert “640” to an integer value 640, that would be 640 in base 10; 640(10) to base 8 would be: 1200

If you pass that decimal 640 to the chmod() function, you'd end up with the sticky bit being set (T in other) along with user write, and NOTHING else. Not 640 as we desire.

So, entering 640 on the command-line would not result in a direct conversion to octal 0640… some converting will be in order.

haas/spring2015/cprog/projects/eocehints.1429395229.txt.gz · Last modified: 2015/04/18 22:13 by wedge