Sodabread 88 Posting Whiz in Training

The reason for your error is that your permutation process stops as soon as your elements are in reverse alphabetical order.

When your code permutes "b", "c", "a", it swaps to cab, then cba, then your first while loop in the permute function determines that b ([1]) is greater than a ([2]), then subtracts from j (now 0), then determines that c ([0]) is greater than b([1]) and once again subjects from j (now -1). The negative one causes the loop to end and the func to return false.

One solution to this is to sort the input into alphabetical order, then do the permutations and that should work for you.

Sodabread 88 Posting Whiz in Training

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

That link should get you to where you could print out the actual form.

As for printing an actual form-like document from an application, there are a couple ways that I can think of to do it, both probably being inefficient as I'm not that good at C# yet.

First, you can design the form in another application like Publisher or InfoPath. Print that out and use that as your paper for printing out form data from your actual form application. It may take you a while to nail down your positioning, but it would work. I know medical offices have applications that do something like this as HCFA forms are done this way many times.

Second, you could spend some time designing the form using the printing framework.

void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.DrawLine(new Pen(Color.Aqua, 2.0), new Point(5, 3), new Point(10, 6));
    e.Graphics.DrawRectangle(new Pen(Color.Azure), 250, 65, 20, 15);
    e.Graphics.DrawString(textBox.Text, new Font("Times New Roman", 12), Brushes.Bisque, 250, 65);
    ...
}
jonsca commented: Good advice +4
Sodabread 88 Posting Whiz in Training

One suggestion would be to just keep the initial click position in a variable at the moment of click, as well as the current held position each frame, draw a rectangle using those points. So instead of doing a while loop, you already know where the initial click was, and your after click continues to update every frame instead of waiting for the mouse to be released.

The way I do my input is by using 3 states: up, clicked/pressed and down. The up state is when the mouse button isn't pressed at all. The clicked state should only be active for a single frame, and that's the first frame of which the mouse button is down. The down state is any subsequent frame after the clicked state in which the mouse button is still down. You can just use a series of if statements in your mouse polling function to determine what effects should take place during states, as well as switching from one state to another.

When you do the input this way, it gives you the ability to handle any mouse click or key press in the same fashion.

Sodabread 88 Posting Whiz in Training

Have you tried just Googling "C# Printing"? Seems there's a lot of good results from that.

Sodabread 88 Posting Whiz in Training

Looking at what's posted here, your main is trying to use exam, exam1, exam2 and exam3, but you never actually declare any of them.

Sodabread 88 Posting Whiz in Training

You can also create the array a after the input of the range as

int a[range]

.

Not exactly. You'd need to use new if you're doing it that way.

int *a = new int[range];
Sodabread 88 Posting Whiz in Training

You can try using a do...while loop and do b = rand() % 10 + 1 while b equals a.

Sodabread 88 Posting Whiz in Training

See your reportResults function. You're declaring both of these variables in that function, but are never initializing them or assigning any values to them. You then try pass them into assignGrade, but they're filled with garbage and C++ doesn't like garbage filled variables.

Sodabread 88 Posting Whiz in Training

You can't use a type like that when you're calling a function. Just pass &rss and you should be fine. You only need the ifstream there when you're declaring an ifstream object or it's in the function definition or prototype.

Sodabread 88 Posting Whiz in Training

What's happening is that in your for loop, you're looping while i is less than range. In your loop, the i++ is executed at the end of every loop, so when you put in your numbers, the i variable is being incremented one more time. If you put in a range of 4 and 4 numbers, the i variable ends up being 4 after the for loop. When you try to access a[4], it's producing that number because it's filled with crap as there's no value assigned to it and it wasn't initialized to anything.

Sodabread 88 Posting Whiz in Training

Initialization is when you set a variable equal to something for the first time. You're never actually setting your variable 'a' to any value, but in line 7, you're setting your 'Enter' variable equal to that 'a' variable.

Also, your if statement condition isn't going to work how I'm assuming you want it to. A single = is assignment, whereas double (==) is the is equal operator.

Sodabread 88 Posting Whiz in Training

You're telling me. Free coffee & hot cocoa, free dinners during crunch time, launch parties at the shore (well, out in CA it's the beach, but I'm from Jersey).

I know it will take entrepreneur-ism, but I don't need those resources anymore. I've found plenty of sites for that point of view, so I'm just now looking for some POV of an industry pro who's done it and is sharing their knowledge.

Sodabread 88 Posting Whiz in Training

Did you ever get it working?

Sodabread 88 Posting Whiz in Training

I didn't really know where to post this, so I figured I'd just go with the lounge.

I'm looking for some business startup resources, but I want something more from the standpoint of an industry professional, rather than that of an entrepreneur. I'd like to do something along the lines of a game development studio or just "plain old" software development, but I'm having trouble finding any resources that aren't just some business guy blabbing about how he does it.

Anything would be helpful, whether it be blog posts, full on websites, forums, etc...

Also, this post is not for people to come in and post "I can make gamez! I can haz job plz?" Do so, and you will be severely downrep'd (by a whole 1), unless of course you can downrep me harder, in which case, have a ball =)

Sodabread 88 Posting Whiz in Training

So, last night I log on to DW and to my surprise, I have a new PM. "Oh joy!", I think, "Someone wants to share a word with me!" To my utter disappointment, I open the message and it just turns out that someone wants to make my fantasies come true. Is this a common occurrence around DW or am I just lucky? Can I forward this message to someone that can take care of it?

Sodabread 88 Posting Whiz in Training

Gah. Duh. You have a semicolon at the end of the for loop. Always the small things that I miss. Damn semicolons.

Sodabread 88 Posting Whiz in Training

Well, first off, that formatting is horrible. You're going to want to start indenting properly if you want much help at DW.

Second, you can't just post and say "It doesn't work" then tell people they need to figure out what's wrong with it. Post your errors or what you're having trouble with so we don't have to compile it ourselves for something that can be figured out by looking at your error and then your code.

Third, your array declarations are incorrect. You can't declare an array using a non-const integer unless you're using new. There are a few ways to solve this.

Declare a const int globally and take the int decks out of your filldecks function and the int decks creation in main:

const int decks = 2;

Use a #define statement instead of a global variable:

#define DECKS 2

Create your arrays using new and pointers:

int **deck = new int*[52 * decks];
for(int i = 0; i < 52 * decks; i++)
    deck[i] = new int[2];
Sodabread 88 Posting Whiz in Training

Your loop variable is fine, your formatting is just really inconsistent.

Sodabread 88 Posting Whiz in Training

And since it's only been 15 minutes since your post, you still have time to edit your post to add code tags and reformat your code so we can read it.

Also, you need to tell us what you're actually having trouble with. No one is just going to finish your program for you.

Sodabread 88 Posting Whiz in Training

Have you written anything, or are you just asking us to do your homework?

Sodabread 88 Posting Whiz in Training

Check out this snippet: http://www.daniweb.com/code/snippet217084.html

Take that information and do a tad bit of research on regular expressions and you should have your answer in no time.

Sodabread 88 Posting Whiz in Training

Nice snippet. I've actually been using something along these lines for some web apps I've been working on.

I do have a question though: Which is faster or more "correct"?

if(object.ReferenceEquals(ctrControl.GetType(), typeof(System.Windows.Forms.ComboBox)))

or

if(ctrControl is System.Windows.Forms.ComboBox)

Is either of those better than the other, or they used for entirely different things? I ask because I'm using the latter, and if the former is a better or more proper use, I'd rather switch to that one.

Sodabread 88 Posting Whiz in Training

Expora, your issues are due to typos. You're passing "drawScene" to the glDisplayFunc function, but your function is named "drawscene". The "initRendering" function called in main is defined as "initRenderind".

Sometimes it just helps to have someone else glance at it =)

Also, about your choice of compiler, just use whatever works for you, rather than what someone says you should use because it's their preference. No offense, Sgt, but people should use what they feel comfortable with.

Sodabread 88 Posting Whiz in Training

www.sourceforge.net. Take your pick.

Salem commented: Now that's what I call a target rich environment :) +20
Sodabread 88 Posting Whiz in Training

Check out gamedev.net. There are a lot of tutorials out there for how to do this kind of thing. I'm not sure what Allegro contains, but you may want to look into some tile engine development stuff. With a tile engine, you could make a separate application to create maps with different tile textures and properties and even multiple layers to get that hide behind object effect. This would also alleviate the need to give exact X & Y coords for each tree/house/etc...

Sodabread 88 Posting Whiz in Training

Your while statement is on the wrong line. It should be at the close of your do loop, but it's currently at the close of your switch.

Sodabread 88 Posting Whiz in Training

You're getting hit by an unexpected case of the recursions!

int sqrt(int num){
	MyException excp("number is not perfect square");
	cerr <<"got Here!";
	double d_sqrt = sqrt(num);
	int i_sqrt = d_sqrt;
	if ( d_sqrt != i_sqrt ){
		throw excp;
	}
	return sqrt(num);

}

Your exception isn't causing any issue here, but you do continue to call your sqrt function over and over and over again. It keeps printing out your cerr because the function is being called by itself every time it gets into itself.

Sodabread 88 Posting Whiz in Training

The variable "rad" is local to the area function. Whatever float is passed in to the area function is called "rad" for the scope of that function.

Your line 7 where it has "area(radius)", it's taking the radius input from the scanf line and passing that variable to the area function.

float area(float);

void main(void)
{
    float radius;
    printf ("Enter Radius");
    scanf ("%d",&radius);
    printf ("Area is %f",area(radius)); // Call the area function and pass in 
}

float area (float rad) // Function that takes in a single float and calls it rad
{
    return (4*3.142*rad*rad);
}

Functions/methods/procedures are pretty necessary parts of C, so it's something you might want to keep reading on until you fully understand how they work.

Sodabread 88 Posting Whiz in Training

Sodabread's sig is pretty good (and concise enough for t-shirts)

It's a great idea for a t-shirt, actually, considering I stole it off a shirt from ThinkGeek.com =)

Nick Evan commented: :) +0
Sodabread 88 Posting Whiz in Training

End thread hijacking NOW!

No, I will not do your homework.

if(DateTime.Now.Year - Thread.Date.Year > 1)
{
    throw new OldPostException();
}
jephthah commented: "no i will not do your homework!" ahah. that's funny. but, you know, [i]we do[/i].... +0
Sodabread 88 Posting Whiz in Training

So, is anyone else planning on going besides myself?

Sodabread 88 Posting Whiz in Training

What about "

...

"?

Salem commented: Nice! +0
Pro2000 commented: Pretty nice :-) +0
JoshuaBurleson commented: love it, I want one +0
Sodabread 88 Posting Whiz in Training

Good catch, void. I think I need to up my C# knowledge a bit.

Sodabread 88 Posting Whiz in Training

Let's try this. When you create your stringbuilder, you immediately append a double apostrophe and then a comma. I'm wondering if an empty set of apostrophes is causing issues. For curiosity's sake, try this:

StringBuilder inAppId = new StringBuilder();

for(int j = 0; j < ServiceList.Count; j++)
{
    inAppId.Append("'" + ServiceList[j].App_Name + "'");
    if(j < ServiceList.Count - 1)
        inAppId.Append(",");
}

I'm kind of fishing for a solution here, but I've come across some row return issues when things look like they should work, but there's non-necessary text in the query string.

Sodabread 88 Posting Whiz in Training

Hmm. When you return that SQL command, are you associating it with a connection object? Also, how are you executing the query?

Sodabread 88 Posting Whiz in Training

I'm not 100% on this, but shouldn't your inAppId variable be a stringbuilder or something similar? Right now, you're trying to add a List as a varchar and I didn't think that would implicitly convert correctly.

Sodabread 88 Posting Whiz in Training

I never had any discussions with him, but his posts always conveyed him as a smart and genuinely good guy who enjoyed helping anyone who needed it. He will be missed.

Sodabread 88 Posting Whiz in Training

In about 40 minutes, I'll be listening to the Demon Days album from Gorillaz. I need to pick up their new one. Has anyone heard it yet?

Sodabread 88 Posting Whiz in Training

I'm sure if you google "basic website template" or something akin to that, you'll find a decent amount of them out there.

Sodabread 88 Posting Whiz in Training

You're trying to write to in_stream3, but you never open a file with it.

Sodabread 88 Posting Whiz in Training

MFC is Microsoft Foundation Classes, and is a Visual C++ thing. It's good if you want to develop Windows apps like Word or Excel, or dialog based utility apps, but it's only for Windows. I always found it kind of fun to develop with, but it's occasionally looked at as being a pain to use.

It would be good to look at to broaden your horizons, but I wouldn't dive exclusively into using it when there are a lot of other options out there to try.

Sodabread 88 Posting Whiz in Training

What about:

string labelName = "label_" = i.value;
Label temp = new Label();
Label.Name = labelName;
Sodabread 88 Posting Whiz in Training

HTML & CSS basics are easy, but there are a lot of things that may not work as you expect them to, so it's good to read up a lot on how it's supposed to work.

You can check out w3schools.com. There's some good tutorials there on both subjects and more. Also, if you want to get heavier into the design of the page, rather than just a basic layout, I've found sitepoint.com can help out a good amount with design techniques and such.

Sodabread 88 Posting Whiz in Training

I've just found DOSBOX and a few abandonware sites. Yipee! Monster Bash and Commander Keen! Duke Nuke'em.

I just love those old id/Apogee platform games.

I miss me some good old Commander Keen. I'd have to say my ultimate PC favorites, though, are the old school Lucas Arts adventures. Loom, Indiana Jones, Monkey Island as well as the non-Lucas ones like Maniac Mansion, Leisure Suit Larry and the Hugo adventures. Nothing like motherboard beeps for music =). Also, Ultima Online used to be friggin' awesome, until they introduced pansy world where everyone could duck away from the thieves and PKs.

Sodabread 88 Posting Whiz in Training

Sodabread has covered what I intended to.

Yeah, sorry about that, F. I started typing, got up for a couple minutes, got back to my desk and finished the post. I guess I was a couple minutes late =)

Sodabread 88 Posting Whiz in Training

You only need to initialize them in one place, but you may have trouble doing this problem in the fashion you're trying to.

Your second question states that you want to return 2 variables from a function, which is not possible. A void return type means the function returns nothing.

Try declaring the variables in main and pass them to your get function as references, then set their final values in that function.

Sodabread 88 Posting Whiz in Training

Has it occurred to you that your plzzzzzzzzzes make it so people want to help you less?

Also, try reading this announcement before posting next time.

ddanbe commented: Well said. +6
jonsca commented: Read my mind actually +4
Ezzaral commented: My thoughts exactly. +10
Sodabread 88 Posting Whiz in Training

It seems that what most people on the outside don't realize about education is that the teacher isn't the single point of success or failure. The kids have to want to learn, and the PARENTS need to be just as involved as the teacher and student. From a younger age, kids need to be shown what a good education can do, instead of just being told they have to go to school and there are no ifs, ands or buts about it. I can't tell you how many times I've heard of parents blaming teachers for their child getting bad grades, not doing their homework and not making up missed tests/work. Parents can make a huge difference in their child's education, but many seem like they're too busy with work and their own life to worry about their kids' futures.

I know there are some teachers out there that work only for a paycheck as there are people in any profession, but the majority of teachers, both that I've had and I've met, care about the kids. If they didn't, they wouldn't be teaching but instead making more money in business. My wife has 2 degrees, one in math and one in physics. She could be making huge amounts of money if she worked as a mathematician or a physicist, but she teaches because she loves it and she cares about the kids. Once you start taking away perks and decent salaries and replacing that with punishment and student …

Sodabread 88 Posting Whiz in Training

Change this and let me know if it works as intended:

if (a1 == 'a1')

to this:

if (a1 == "a1")

If you have more than one character, you need double quotes. Double quotes for strings, single quotes for single characters.

Sodabread 88 Posting Whiz in Training

Well, string would be the variable type you want.

You should be able to use it like this:

std::string x;
std::cin >> x;

If that doesn't work, you can try using:

std::string x;
std::getline(std::cin, x);

The first method should work fine, as it's a single "word" of input. Getline is more for multiple words w/ spaces, at least as far as I've used it.