I actually can't figure out why it's decrypting that much. It should never decrypt more than 32 bites of data because that is the maximum password size and all your loops only go that far. an alternate solution that didn't include so many temp variable might also look like this
void...
I have an application where I have to read in large quanties of data from a file. The records are mixed binary and ascii having no standard format save a 4 charachter delimiter at both the beggining and end of a record. The delimiter is assummed but not garunteed to only occur there and not in...
...then subtracts all the values from it. whats left is what we are missing
unsigned int findmissing(unsigned int low,unsigned int high,unsigned int *list)
{
unsigned long pairsum(low+high);
unsigned long numpairs((high-low+1)/2);//We are counting on trucation
unsigned long...
I am processing files of our SAN, to minimize network load and load on the SAN (it is an issue in my enviornment) I want to cache the entire file to memory when it's opened. Writing my own file class is what I'm doing right now, but I am finding out how much of a pain it is. The file is part...
it makes sure what you've written is on the screen and not just buffered. The same idea applies to an ofstream as well.
http://www.cplusplus.com/ref/iostream/ostream/_flush.html
WR
I only have vis 7.0 and it compiled fine, however
1: use iostream and namespace std
#include <iostream>
int main()
{
using std::cout;
using std::endl;
cout << "Hello World"<<endl;
return 0;
}
2: specify that main have a return type of int...
1:Where do you allocate the memory for tmp? do you use new or point it at a char[] declared on the stack
2:That code just changes the first char, it doesn't append.
3:a \0 never gets put in so any string handling functions are going to run off the end.
WR
I am trying to write a program to verify that a hard drive can store data without corrupting it.
I have written a class called randomData that is filled with a std::vector of 1k std::strings. The program prompts you for how big you want to make the class and then how times you want to repeat...
teriviret- thanx for the tip, I didn't know you could do that.
obislavu- I like the first solution too cause there's less room for screwing it up when you code it. It all comes down to how fast the % operator is
With the first one recordsparsed%threshold must be computed for every iteration...
...the generally acceppted best practice is.
//version 1
std::ifstream in("somefile.txt");
long buffersize=10000;//size of text buffer
char *tempc=new char[buffersize];
usigned long recordsparsed=0;
int threshold=500;//only output every threshold records
while(!in.eof())
{...
If you implement the == operator and the < operator, you can store your struct in a standard container like a list or vector and use the containers built in sort algorithim.
WR
...internal data. Run the following demonstration code to get a better idea of what I mean.
class Test{
public:
void setFirstname(char *firstname){
strcpy(_firstname,firstname);
}
char *getFirstname(){
return _firstname;
}
private:
char...
What version of the librarys are you using? The following code leaves my c:\ untouched
#include <iostream>
#include <fstream>
void main()
{
std::fstream in;
in.open("c:\\dontcreateme.txt");
}
if you are using the versions found in the .h files you can
1:not (preferred...
Why don't you use the debuger to look at the internals of the exeption class. If you can't get anything readable from that at least you know what kind of class is beeing thrown. You can 1:see if it has any member functions or variables that might help diagnose the problem and if so you can trap...
I noticed that your code used <iostream.h> most of the standard .h files are deprecated and you can't mix and match old .h's with the the new ones. Note this only applies to the standard libs.
use <iostream>
ex
#include <iostream>
using namespace std;
int main()
{
cout << "Hello...
By returning a char * from getFirstname you allow your callers to mess with the underlying data which kinda defeats the purpose of encapsulation.
You can return a const char * so users can't screw with the data
---or---
you can return a copy of the data there are two ways of doing that
1: Use a...
Why does searching the map take O(n)? Assuming that your implementation obeys the complexity rules of the STL and isn't just a set of classes it should only take O(log(N)) time shouldn't it? http://www.sgi.com/tech/stl/SortedAssociativeContainer.html
WR
...down a solution here is the code the demonstrates it.
#include <iostream>
#include <stdio.h>
#include <process.h>
int _tmain(int argc, _TCHAR* argv[])
{
std::cout<<"Items written to stdin:"<<fwrite("test\n",1,5,stdin)<<std::endl;
FILE* out...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.