[cs33211] Project 3

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Nov 25 20:30:27 EST 2012


> But when its says in project "8th reference (in i-node block) is to
> a single indirect block" won't I have to store an integer in that
> spot in the text file? And then take the address and use it to
> computer the offset for pwrite()? This is where I am getting tripped
> up, maybe I don't even have to do that though.

char type can store numeric values. You can write:

     unsigned char myBlock = 42;

you can convert an integer to char if you like.

    int myInt=42;
    unsigned char myblock;
    myblock = char(myInt);

Note that on x86 architectues char type size is 8 bits. Therefore the
maximum value it can hold is 255. If you assign a larger integer to
it, the higher bits will be lost. For example:

  int myInt=256;
  unsigned char myBlock;
  myBlock = char(myInt);
  cout << int(myBlock) << endl;

prints zero.

Thanks,
-- 
Mikhail


More information about the cs33211 mailing list