c++ - logical drive letters are not displaying -
i have written small program search logical drives in pc , prints them. differnt wirh expected, not displaying them.. here code sample
tchar szdrive[] = (" a:"); dword drive = getlogicaldrives(); printf("the bitmask of logical drives in hex: %0x\n", drive); printf("the bitmask of logical drives in decimal: %d\n", drive); if(drive == 0) printf("getlogicaldrives() failed failure code: %d\n", getlasterror()); else { printf("this machine has following logical drives:\n"); while(drive) { // use bitwise and, 1รข€"available, 0-not available if(drive & 1) printf("%s ", (const char *)szdrive); // increment, check next drive ++szdrive[1]; // shift bitmask binary right drive >>= 1; } printf("\n "); }
your printf statement broken. use this:
printf("%s ", szdrive);
i guess use of %s
instead of %s
typo.
Comments
Post a Comment