GOT IT
Code:In new post
GOT IT
Code:In new post
Last edited by bikr692002; 04-05-2006 at 06:04 PM.
Perhaps you are not familiar with the C and C++ definition of byte. This may explain it better than me.Originally Posted by ChaosEngine
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Ugh, is there any other way to make the Secure Disk Cleanse loop faster?
Code:#include <stdio.h> #include <fstream> #include <iostream> #include <windows.h> int main() { long end,Oend,begin,Obegin; std::string Dir,File,Option; int Loop,SizeOfDisk,SizeOfFile,OrigSizeOfFile; Loop=1; std::cout<<"Welcome to C.J.'s Security 'suite'!\n"; std::cout<<"Please enter what you want to do.\n"; std::cout<<"To select Secure Disk Wipe, input SDW.\n"; std::cout<<"To select Secure Disk Cleanse, input SDC.\n"; std::cout<<"To select Secure File Deletion, input SFD.\n"; std::cout<<"To select ---this option is not yet available---.\n"; std::cout<<"To select ---this option is not yet available---.\n"; std::cout<<"Option:"; getline(std::cin,Option,'\n'); if(Option=="SDW") { std::cout<<"Sorry,This option is not yet available"; std::cin.get(); } if(Option=="SDC") { std::cout<<"Please enter Disk(Ex. C:\\):"; getline(std::cin,Dir,'\n'); if(Dir.length()!=3) { while(Loop==1) { File=""; std::cout<<"\nPlease enter Disk:"; getline(std::cin,Dir,'\n'); if(Dir.length()==3) { Loop=0; } } Loop=1; } File=Dir; File="SecureDiskCleanse.txt"; std::ofstream a_file(File.c_str()); while(Loop==1) { typedef BOOL (WINAPI *PGETDISKFREESPACEEX)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); PGETDISKFREESPACEEX pGetDiskFreeSpaceEx; __int64 i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes; pGetDiskFreeSpaceEx=(PGETDISKFREESPACEEX)GetProcAddress( GetModuleHandle("kernel32.dll"), "GetFreeDiskSpaceExA"); GetDiskFreeSpaceExA( Dir.c_str(), NULL, NULL, (PULARGE_INTEGER)&i64FreeBytes); a_file<<"Secure Disk Cleanse."; SizeOfDisk=i64FreeBytes/1024/1024; if(SizeOfDisk<100) { Loop=0; } } a_file.close(); File="DEL "+File; system(File.c_str()); std::cin.get(); } if(Option=="SFD") { std::cout<<"Please enter file path and name.:"; getline(std::cin,File,'\n'); std::ifstream OrigSize_file(File); Obegin=OrigSize_file.tellg(); OrigSize_file.seekg(0,std::ios::end); Oend=OrigSize_file.tellg(); OrigSize_file.close(); OrigSizeOfFile=(Oend-Obegin); std::ofstream a_file(File.c_str(), std::ios::trunc); while(Loop==1) { std::ifstream Size_File(File); begin=Size_File.tellg(); Size_File.seekg(0,std::ios::end); end=Size_File.tellg(); Size_File.close(); SizeOfFile=(end-begin); a_file<<"Secure File Deletion."; if(SizeOfFile>(OrigSizeOfFile+10)) { Loop=0; } } a_file.close(); File="DEL "+File; system(File.c_str()); std::cin.get(); } else { std::cin.get(); } return 0; }
Are you referring to me or Ancient Dragon?Originally Posted by Dave_Sinkula
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?
Possibly both.Originally Posted by ChaosEngine
It is possible for a "32-bit system" to have a char that is 32 bits. It is possible for a "32-bit system" to have a char of 8 bits.
It is possible for a "64-bit system" to have a pointer that is 64 bits. It is possible for a "64-bit system" to have a pointer with 32 bits.
It is possible for a "64-bit system" to have an int that is 64 bits. It is possible for a "64-bit system" to have an int with 32 bits.
I am beginning to much prefer the ILP32, ILP32LL, etc. conventions for descriptions -- although it still doesn't fill all the gaps.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
I am aware of the ILP notation. As I said previously, my original post was an oversimplification. A "64-bit system" refers to the width of the address bus and has nothing to do with the char size. Of course it is possible for a 32, 64 or 128 bit system to have their char type as those sizes, but it's very rare in practice, and what I was trying to correct was Ancient Dragons implication that a 64bit system will always have a 64bit char type.Originally Posted by Dave_Sinkula
I believe on win64 it uses IL32P64. As far as I can see, however a char is still 8 bits.
Last edited by ChaosEngine; 04-06-2006 at 04:17 PM.
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?
Only 1 if you re-use it :-)Originally Posted by bikr692002
>>trying to correct was Ancient Dragons implication that a 64bit system will always have a 64bit char type.
After re-reading my post -- I see it is technically incorrect as you mentioned. The point was that there is no standard number of bits in 1 byte. sizeof(char) will always be 1 regardless of the number of bits.