pseudorandom21 166 Practically a Posting Shark

I was referring to the algorithm. Tweaking the parameters (slope_max, slope_change and line_length) can
produce interesting results. Making slope_change and line_length variable can also yield very interesting results.


There's nothing wrong with hacky multi-line macros. On the contrary, they make my code more boost-like :D

Noo! That's what inline functions are for..

pseudorandom21 166 Practically a Posting Shark

Nevermind, bad question.

I remember needing to write a program that generates curve functions, as in specify a begin point an end point and a point or points the curve needs to pass through. Sadly I never got around to it.

But! My math teacher told me it involved solving three or more equations .. or something.

pseudorandom21 166 Practically a Posting Shark

I'm no licensing expert but I do know that I hate the GPL, what if someone wants to use a part of your code in a product, or something that you don't want to give the source away? What if *you* want to use a part of it in something you don't want to give the source away? The GPL is just a license saying "you can't sell this and you have to give source code if you use it".

F' the GPL and the "Open Source Initiative" free the code!

The way I see it the GPL is imposing restrictions on the finished product and I don't think that's a good thing. I, understandably as a developer, want free source code instead of free software.

jwenting commented: well said +0
pseudorandom21 166 Practically a Posting Shark

vector will not work because I haven't learned about them yet. So I have to do this using arrays.

Did my post help you any?

xxlt3xx commented: very helpful thank you +0
pseudorandom21 166 Practically a Posting Shark

I think use the vector is better.

vector<int>  neg;
	vector<int> posEven;
	vecotor<int> posOdd;
if (input number<0) poseven.push_back(number);
else if( number>0 && is_Even(number) ) posEven.pub_back(number);

Yes I also agree that the vector is better, it's up to the poster to decide what he wants to use.

pseudorandom21 166 Practically a Posting Shark

Does this help?

using namespace std;

const string FILENAME = "INTEGERS.TXT";
const string AUTHOR = "Rf";
const string ROLE = ", (s)\n";
const string SOLTXT = "\nSolution by ";
const string INFILE_ERR_MSG = "File does not exist or it is empty!\n";
const int EXIT_ERR_INFILE = -1;  // Error with input file

const int MAX_INT = 500;

bool openFileForInput(ifstream&);
bool getNum(ifstream &inp, ofstream &otp);


int main()
{
	srand ((unsigned int)time(NULL));

	/* Populating INTEGERS.txt */
	ofstream outData(FILENAME.c_str());
	int base = -250;
	for (int i = 0; i < MAX_INT; i++)
		outData << base + rand()%500 << endl;
	outData.close();

	/* Processing INTEGERS.txt */
	ifstream inData;
	if (!openFileForInput(inData))
	{
		cout << INFILE_ERR_MSG;
		system("PAUSE");
		return EXIT_ERR_INFILE;
	}
	
	cout << endl << endl;
	system ("PAUSE");
	return 0;
}

// Open a file for input
// Check for existence of file in current directory
// If file exists, is there any data in the file
bool openFileForInput(ifstream& inp)
{
	inp.open(FILENAME.c_str()); // See if we can open
	inp.peek();  // Determine whether file is not empty
	return (inp && !inp.eof()); // checks if the file exists and not empty
}

bool getNum(ifstream &inp, ofstream &otp)
{
	//Let's start with 3 arrays.
	int neg[MAX_INT] = {0};
	int posEven[MAX_INT] = {0};
	int posOdd[MAX_INT] = {0};
	//Let's also use 3 size_t to store our
	//current index as we populate the arrays.
	size_t negativeSize, positiveEvenSize, positiveOddSize;
	negativeSize = positiveEvenSize = positiveOddSize = 0;

	int temp = 0;
	while(inp >> temp) //<-- this is a safe mechanism for reading the file.
	{
		//Using …
pseudorandom21 166 Practically a Posting Shark

I tend to think Iterators are more of an idea than being tied to a single implementation. A predefined function is one that is implemented already.

Stl algorithm: std::random_shuffle( someVector.begin(), someVector.end() );

pseudorandom21 166 Practically a Posting Shark

You have to call that function somewhere in the program. I'll leave it up to you to figure that one out.

pseudorandom21 166 Practically a Posting Shark

Don't modify your header files!!!! At least the ones that come with the compiler anyway.

pseudorandom21 166 Practically a Posting Shark

Sounds like a great opportunity to use boost!

pseudorandom21 166 Practically a Posting Shark

No, he means another thread. C++ currently doesn't come with a platform independent way to spawn threads, so you'll have to either rely on Operating System API calls, or use a library (I recommend Boost).

There are plenty of examples of both ways and I suggest reading some tutorials on multi-threading w/ C++ first.

pseudorandom21 166 Practically a Posting Shark

Lol I hate to say it but Dev-C++ is a poor choice also, it's buggy and no longer supported as far as I know.

Code::Blocks and Visual Studio express are the best IDEs for Windows, in my opinion. VS2010 express won't let you down I'm sure.

As far as what you have posted goes, rand()%90 returns of course 0 to 89, and is it uber-important to do this using the raw Windows API? I'm sure you could use QT, wxWidgets or Winforms and you could probably understand it a lot better.

pseudorandom21 166 Practically a Posting Shark

@Narue, maybe it's just a poor choice of variable name?

pseudorandom21 166 Practically a Posting Shark

Where did this tInches from from?? That doesn't rely on input from the user at all, so it begs the question, what is it doing??

Also, saying 67 inches is:

and then using 43 inches in your calculations doesn't make any sense man!!

pseudorandom21 166 Practically a Posting Shark

My guess is that there is an event that is raised every time the text changes, find that event and add the proper handler. In your handler I'm guessing you'll need to use the EventArgs (or similar) information to determine if the space was entered.

Really, my guess is that you can google this pretty easily when you're looking through the events to find the one you want.

After a google search I hath found keydown, keypress, and keyup events for that control.

Those will definitely work just fine.

Also, I just tested this and it works.

dotancohen commented: Thank you very much! +2
pseudorandom21 166 Practically a Posting Shark

fmod(something) == 0 should be fmod(something) == 0.0 Otherwise a slight error might be because of limits of the representation of floating point numbers.

pseudorandom21 166 Practically a Posting Shark

@Tellalca,

Your logic is terrible.

pseudorandom21 166 Practically a Posting Shark

I like programs that support command line arguments. There, there's my opinion, now I'll just brace for the backlash.....

Narue commented: Me too. :) Console filters aren't common anymore, but they're super useful. +17
pseudorandom21 166 Practically a Posting Shark

That doesn't look very C++ish to me, specifically because you're using a C function.

You can more than likely use a C++ std:;string, couldn't you? The c_str() member returns a const char *.

http://www.cplusplus.com/reference/algorithm/
http://www.cplusplus.com/reference/string/string/

A C++ stringstream may fulfill your tokenization needs, http://www.cplusplus.com/reference/iostream/stringstream/

pseudorandom21 166 Practically a Posting Shark

You haven't provided an implementation for it.

~dayType();

pseudorandom21 166 Practically a Posting Shark

Much agreed, the format of your post is most unhelpful to us. It's really your responsibility to make sure you meet those requirements, and if you're having trouble or you have a specific question we'll surely help.

pseudorandom21 166 Practically a Posting Shark

http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx

This may help you, it says that the function called doesn't need to be known at compile-time. I guess I should wonder, how else are you going to pass a function to a function?

pseudorandom21 166 Practically a Posting Shark

Calling the primary thread's invoke member executes the function on that thread instead of the new one.

pseudorandom21 166 Practically a Posting Shark

Oh wow, I think this forum has a bug! I definitely posted that somewhere else. I've had other forums do this to me too... Hmm.. Maybe it was user error then, oh well. Disregard that.

pseudorandom21 166 Practically a Posting Shark

If you're using Vista or W7 you may need to give your application administrator privileges to modify something in the root directory like that.

pseudorandom21 166 Practically a Posting Shark

Dev-C++ is no longer supported, last I checked. A better IDE will probably compile it.

pseudorandom21 166 Practically a Posting Shark

Try checking your GLUT install then.

Also, I think you're leaking your key states array. (need to delete the memory)

pseudorandom21 166 Practically a Posting Shark

hmm, if you're using Windows have you tried running the application in administrator mode? Just making sure that wasn't overlooked.

pseudorandom21 166 Practically a Posting Shark

There are plenty of data structures useful for sorting, but the problem is that you are trying to store the entire file in memory. Obviously a solution is to not store the entire file in memory. It can be done.

pseudorandom21 166 Practically a Posting Shark

Press F5.

pseudorandom21 166 Practically a Posting Shark

Well... Being overly generous to the pyschopath side, I got a 5.

I do know a friend who would probably get like a 20-30 at least, however.

pseudorandom21 166 Practically a Posting Shark

probably want to include windows.h before any other includes.

pseudorandom21 166 Practically a Posting Shark

Once you drag + drop a "control" on your "form" you can select the control and in the properties pane at the top there is an "events" button you will want to click.

Those events are most likely relevant to using your logic with your GUI. Find one, such as the "MouseClick" event, double click the white part of the drop-down to have the editor generate one for you.

pseudorandom21 166 Practically a Posting Shark

This is incorrect:

char password;
    char PASSCODE="mypasscode";

Typically you will use for C style strings:

const char *PASSCODE = "mypasscode";

to compare C style strings ( which is an array of characters with a NULL character to signal the end of the string ) you will need to use strcmp().

I'm thinking if you are reading a tutorial it has introduced C style strings in order for you to understand some basics about pointers. It probably also introduced the array, which you will need to use.

Alternatively, there is a C++ "string" class.

pseudorandom21 166 Practically a Posting Shark

void __cdecl showArray(char (* const)[4],int)

needs a definition, even if it's empty--then it will compile properly.

Your prototype (declaration) differs in parameter type: void showArray(char [][guess_cols], int );

pseudorandom21 166 Practically a Posting Shark

Never mind this post.

pseudorandom21 166 Practically a Posting Shark

Google "Dynamic Memory Allocation C++"

int bufferSize = 512;
char *buffer = new char[bufferSize];
strcpy(buffer,"This fits in my buffer.");

//When finished you must delete the memory
//or it will be a memory "leak"
delete [] buffer;
pseudorandom21 166 Practically a Posting Shark

"::" is the scope resolution operator.

namespace::class is the form of std::string.

pseudorandom21 166 Practically a Posting Shark

I think it has to do with the way the C++ compiler works. It's all the C programming language's fault (most likely).

pseudorandom21 166 Practically a Posting Shark

I think you may experience link errors with your current setup.

You need to have the code inside the header file for templates (no source file, header only).

Truthfully you can include the .cpp file at the end of the .h file, but if you're using Visual Studio you will need to exclude the .cpp file from the solution to do that, and it's not worth the trouble at all. For G++ I'm not sure how that would work.

pseudorandom21 166 Practically a Posting Shark

A pointer is probably the same size as an integer, so you probably won't gain any resources by using pointers when passing simple integers, but take a structure for example.

(C++)

struct SomeType{
int x;
int y;
char name[128];
float delta;
std::string etc;
};

If you use a pointer or reference you won't copy the entire structure's contents.

void foo(SomeType * const st){
	strcpy(st->name,"Bob");
	st->x = 100;
	st->y = 50;
	st->delta = 1.0f;
	//Constant pointer so you don't
	//change what the pointer points to.
	//error:
	//SomeType s;
	//st = &s;
}
pseudorandom21 166 Practically a Posting Shark

Hey those variable names don't look very descriptive, sometimes a meaningful name is helpful.

pseudorandom21 166 Practically a Posting Shark

Here's an even more-complicated way to print the contents of a string.

std::string inputFirst = "Clearly.";
	std::copy(inputFirst.begin(),
		inputFirst.end(),
		std::ostream_iterator <std::string::value_type> (std::cout));
pseudorandom21 166 Practically a Posting Shark

We need to know about your "string array".

pseudorandom21 166 Practically a Posting Shark

I'm not saying this is the best way to do what you want, but you can #ifndef out a block of code:

//#define TESTING

#ifdef TESTING
void Test(){ //<-- inactive pre-processor block.
}
#endif
#ifndef TESTING
void Real(){ //<-- Active code.
}
#endif
pseudorandom21 166 Practically a Posting Shark

Hey couldn't some IPC simulate some multi-threading? I.e., spawn a few different processes as "threads".

pseudorandom21 166 Practically a Posting Shark

I would consider creating a DLL for commonly used functions.

pseudorandom21 166 Practically a Posting Shark

MSDN says: http://msdn.microsoft.com/en-us/library/ms645489(v=vs.85).aspx

See under the "Initializing a Text Buffer" section here:
http://msdn.microsoft.com/en-us/library/bb775456(v=vs.85).aspx#text_buffer

pseudorandom21 166 Practically a Posting Shark

At least make the effort to put into words what you're too lazy to do.

Fbody commented: I'm not too sure this was necessary... :( -1
ddanbe commented: You did not deserve the neg rep! +9
pseudorandom21 166 Practically a Posting Shark
std::vector<int>::iterator it = myVec.begin();

Please see here: http://www.cplusplus.com/reference/stl/vector/begin/