Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange DiskSize()

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
Greetings all....
I'm working on a "Whereisit" clone and this is probobly just a blunder of mine, but I can't find the cause!!
when i use this code
Code:
 static char * Drive_Letter[]=
 {  // Drive letters
    "A:\\","B:\\","C:\\","D:\\","E:\\","F:\\",
    "G:\\","H:\\","I:\\","J:\\","K:\\","L:\\",
    "M:\\","N:\\","O:\\","P:\\","Q:\\","R:\\",
    "S:\\","T:\\","U:\\","V:\\","W:\\","X:\\",
    "Y:\\","Z:\\"
 };
for( int i = 0 ; i<26 ; i++ )
   {
    int disk_size = 0;
    disk_size = DiskSize(i+1);
   }
(can't remember why I do DiskSize(i+1)
I get the disk_size on my C: to be -11447500080 How can this be? I have a 4gb hdd partitioned to c: -> 3gb and d: -> 1gb, d: though this should not be a problem! D: comes out fine and shows 905 mb! I know this could should work beacuse I've used it before, perhaps made something wrong when I wrote it again... but I just can't find it!! My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Where are you spitting out disk_size? If it's not in the for loop the variable may no longer point to the correct memory location. The other thing to look at is if disk_size should be unsigned. Just a couple of thoughts at first glance.
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Stupid me... I forgot I was working with large numbers, largen then an integer can handle!! The size of the disk is 3150217216 bytes, and I don't know where the limit of an integer is! (never took much care for that, now I see why it's good to know)...

thanks anyway! =D
My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top