jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would just eliminate that parameter, as you are creating a new ifstream object within the body of the method anyway. You may want to rethink your implementation a bit, because all you are doing is writing to the same int value over and over again, and that int is being destroyed once you leave the method anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have a look at this (there's a nicer version for VS 2010, it's probably virtually the same set of keybindings).

Mr. K commented: THanks Jonsca +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On line 64, you are attempting to parse the data without having any data yet. Put your getline statement first (before your parsing statement), then put a statement to split your string in two (into first and last), and then finally call parse2() .

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why not declare a string empty val and input it in between t[lcv] and Z[lcv] to achieve the spacing?

The extraction operator (>>) takes input delimited on spaces. The way the OP has it is fine.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have a question as to why you are displaying in your add method. Your add method should do nothing more than add the two numbers together. You may want to check with your specification to make sure that your code is not supposed to add the two together and return a reference to a third number. Either way, though, your display should be separate from your operations.

Seeing if your imaginary portion is 0 takes an if statement in the display function. If you want to choose which form to display (,) vs a+bi, I would say add a parameter to your display function (with a default value of one way or the other) which governs how the output is printed.

Otherwise, you need to be a bit more specific rather than saying "need something here." You are the one that knows this program best at this point, you need to present it to us as if we've never seen it before.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the error. Please be specific.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Posting your question on multiple sites is inconsiderate.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
char *text;

You have an uninitialized pointer here, and a few lines down, you try to store something in it. Allocated memory for your C-string using new.

Why do you close the file before you open it in the beginning of the code?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have you tried compiling it? There's quite a few syntactical liberties in there. :)

char[]* LongArr;

is not valid syntax.

Where does numStr in the constructor come from?

Where does i come from in getInt() ?

new int* int1

new doesn't belong on the left side of that expression

I think some of the ideas are starting to come together, but study some examples from your text or otherwise and take another crack at it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did your instructor go over passing parameters by reference. You need those techniques in this case. For instance, the getName signature would look like:

void getName (string & firstName, string & lastName)

Otherwise, you are just passing in copies of those variables, the changes are being made, and they are lost once the function ends.

Line 119 is plain wrong. A function can only return a single value. Also use the pass by reference technique with those parameters.

Just an aside, you should avoid global variables (except under very specific cases).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

C# is foor n00bs

Be sure and let him know that. ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When I want z value to write in Textbox form window.

That doesn't happen by magic. Go through http://www.functionx.com/vccli/general/introprogramming.htm which will tell you a little about accessing GUI elements. You'll have to make sure you have the right kind of project selected (winforms). In addition, the syntax of the (loose) "dialect" of C++ that is used with them is C++/CLI, which is covered in that site I gave you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to be much more specific about your requirements before anyone can even begin to help you. Since you only have 1 week, you're going to have to be conservative about your goals, as some of these libraries take months to learn.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try starting a new project and copying and pasting the code from the existing one into the new one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use an ifstream object and the extraction operator >> to get the values. As you read them in, loop over the members of your array and write them in. Take another shot at it and post back if you are still having trouble.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How do you input the string in the first place?

If you're ignoring nulls then don't use strlen. Step through the string and when you hit a null and you haven't hit the end of the array, then see what the next character is. I'm sure there's a more clever way to do it, but see if that works.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure of the exact implementation, but I was saying for yours, add a member variable to each Str that is called length (it could be public, but it's probably better off private with an accessor). Use that to gauge how many character will be in the concatenated Str, and allocate the space accordingly.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In readFile, first you use std::string and then you use C-strings. You should pick one and be consistent. If your concern is getline there is a version that is a member method of istream (http://www.cplusplus.com/reference/iostream/istream/getline/). Also, line 35 will not work.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you're not going to null terminate, somehow you have to indicate the length of the string. You could have your custom string class carry around a length member (or member function to return the length).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Better you must read it properly....

Better you reread the thread because you don't seem to understand the clear explanation that Narue was giving about undefined behavior.

Killer.bee commented: Ohh i think you need to rereas -1
Nick Evan commented: counter. +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out Curl (standalone program) and libcurl (C library which has C++ wrappers) http://curl.haxx.se/

However, you can interact with a database directly from your C++ code (using whatever bindings your database has, or a generic ODBC driver), so there's no need to interact through the web server.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The game board is the tricky part because it's not square. It's probably most convenient to make it a square and then do bounds checking to make sure the move you are going to make is still on the board. You should probably do this in the move function with a series of if statements. You can also adjust your board within the move function.

Your displayboard function doesn't make much sense. Just output it using a loop like you were trying to do in the main function. Adjust the bounds on your for loops to print out only the valid portions.

Keep going with it, and test it incrementally to make sure all of the parts are working before moving on.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

By virtue of C# being the more prevalent .NET language, most of the tutorials don't use the C++/CLI syntax. You're better off looking at a C# site like http://www.c-sharpcorner.com/Articles/ArticleListing.aspx?SectionID=1&SubSectionID=167 and trying to translate the syntax (sticking in :: and -> when needed).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What steps have you taken in starting to solve the problem? Have you decided on how you will represent the board? Are you going to use classes? These are the things you need to think about and start sketching out on paper even before you begin. Write as much of the code as you can, and post back with specific issues.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

At the time I wrote that I didn't know which one it was.

Yes, I know. I was just giving you the stack trace of my brain fart. :) I'm again sorry for steering things the wrong direction... (means I have to bow out, too, as I know next to nothing about MFC)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How did this topic turn from MFC to Windows Forms?

That's on me. I misinterpreted something you said.

I have tried OnOK(); this->CloseWindow()

In Windows Forms CloseWindow()...

as meaning that he was doing Winforms.

Apologies.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Assuming you added 2 textBoxes to a groupbox programmatically and that those were the only 2 controls there

groupBox2 = gcnew GroupBox();
groupBox2->Controls->Add(textBox3);
groupBox2->Controls->Add(textBox4);
this->Controls->Add(groupBox2);
for each (Object^ ctrl in groupBox2->Controls)
{
    MessageBox::Show((static_cast<TextBox^>(ctrl))->Text);
}

(if you had other controls in it, you'd have to know what order they were in, etc).

They can also be addressed as groupBox2->Controls[0] and groupBox2->Controls[1] Since there's no is/as in C++/CLI like there is in C#, I've found that using the Tag property of the control comes in handy. You can assign a string to it (or any object really) and sort your controls based on that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can either do it in the forms designer (drag the groupbox control over and place the other items inside of it), or you can do it programmatically

instantiate a new groupbox
instantiate a new control of whatever type
add it to the groupbox
instantiate a new control of whatever type
add it to the groupbox
add the groupbox to the 'Controls' object of the main form.

Try that out and post back if you can't get it to work (or with any other issues).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Good to know. I'll have to keep my eyes out for some guidelines about this kind of thing. I'm starting to figure out a bit more about the optimizations of the managed code and the juggling act that goes on with the unmanaged pieces, but in terms of the settings it's confusing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What /clr setting do you have set for the compilation? If you don't have any on there, it will try to compile your code as native.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You mean to insert prototype ?

I mean that you try to instantiate both classes, but they have not been written. That will give you an error or two. As others have mentioned, you haven't defined the abstract class that both of those will inherit from, either.

Can you show me how do i need to arrange it with my code

You probably want to put your class declaration for each (the base class and the two child classes) each in its own header file. It's not absolutely necessary, but it will keep things organized and neat. Then, you can put the implementation for each of the child classes in its own .cpp file.

Look for some examples of separating out the class files in your text or online. You're most of the way there, now you have to fill in the gaps.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where is the code for UpperCaseFilter and EncryptionFilter?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not familiar with C#

All you have to remember is that C# used '.' for both namespaces (which would use '::' in C++) and member variables/methods (which would use either '.' or -> to access a class/struct depending on whether the variable is a pointer or not).

I agree with AD, if you're using C++/CLI, use the available methods in .NET.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you know how to do all of the transformations from a mathematical standpoint (i.e., pencil and paper)? If not, first start with a good reference book or Wikipedia article and figure out the mechanics of it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not 100% sure that deleting data will free that memory (if someone can check me on that) since you are passing it in via the initialization list.

You should be able to use strlen and related functions on the string that's being passed into the constructor. That way you can allocate exactly how much you need.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How big is your string that you allocate as temp?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Delete line 5 of Form1.cpp and move lines 20-24 out of Form1.cpp and into a new file xxx.cpp. It shouldn't make that much of a difference, but it's good to keep Form1.cpp clean.

I had told you that in xxx.h, you need to qualify String^ as System::String^ as the compiler has no notion of it otherwise.

System::String ^ParseBBCode(System::String ^OriginalText)[B];[/B]

(you didn't have the semicolon after the declaration, but I'm not sure if that was a typo.

emanfman commented: you helped very much. thank you! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're calling the function in Form1.h, correct? As long as your .cpp file is part of the project, everything should be fine. No, do not move the body of the function to the header.

It's confusing because in the Winforms programs, the Form1.h also contains a lot of definitions. If you have included the one line header in Form1.h, are calling the function in Form1.h, and have the associated .cpp file with the body of the function as a part of the same project, you've done all you need to do.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put it in a file named something like "ParseBBCode.h". Include that header in your Form1.h file (or put it in stdafx.h, but that's not necessary). You do not need to include <string>, the String ^ in this case is a System::String^ from .NET.

You will either need to put a using namespace System; at the top of your header (not a good idea, as everything that includes it will now have that namespace) or qualify your String^s in the header as such:

System::String ^ ParseBBCode(System::String^ OriginalText);
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

is it possible?

Yes.

I'm assuming you're using C++/CLI with Winforms? Place your images in a List<Bitmap> and make a "surrogate" array of integers from 0 to 15. Use a Fisher-Yates shuffle on that array of integers. Display the items of the list in the order that is defined by the shuffled integer array.

See where you can get with that, and post back with any specific syntactical issues that you have.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need the type of the variable when getting the input (on lines 32, 34, etc). Also, look up what your function definition is supposed to look like, lines 26-28 make no sense.

There are a few other issues, but, as WaltP has stated, there's no question here. I know it's a pain to catch up on your work, but do the best you can with the resources that you have (notes, textbook) and post back with something like, "well, my function does this when I put inputs X, Y, and Z into it, but I'd expect it to do something else."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How about the daniweb mods be the new government

Yes, and I'm sure before long they'd be passing out Kool-Aid.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm assuming that you're working in C++/CLI since you are doing WinForms. Check out the BackgroundWorker, as I believe that's the most straightforward way of getting a separate thread (and I believe it was designed for exactly this purpose, i.e. for separating the GUI and the meat of the code).

Just make sure you're not running life support systems or nuclear missile silos with these motors. If that's the case, you'd probably want something embedded.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

My personal favorite is George Washington, a true hero and very smart.

Don't the (perhaps fictional) wooden teeth freak you out?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ancient dragon for President :P

But he's only 34!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The money's not the best

Everybody always says that, but they forget that there are just so many perqs beyond the salary (not to mention all the book deals and speaking engagements afterwards are probably enough to keep them afloat). I'll bet the president doesn't pay for internet and cable ;)

FWIW, I think William Henry Harrison was the best president ever.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

May I respectfully disagree.

You certainly may.

Nobody even attempted to understand the question, except Adak.

I think we all attempted to understand the question. I don't think this is the type of question that any of us are used to hearing around here.

or the person explaining it to you had no idea what they were talking about.

Perhaps I should soften that statement a bit. They obviously know exactly how much you can get away with when dealing with the compiler. Whether that's a good skill to have is probably debatable.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sir, you can check the link:-

http://www.spoj.pl/problems/SIZECON/

(I'm going to weigh in, even though I probably shouldn't)

OP, what you have written is not legal syntax, it doesn't compile, and either you misunderstood the solution explained to you or the person explaining it to you had no idea what they were talking about.

gives a reason to teach things you've not be asked for

I understand your point, but I don't see what has made the response to this thread outside of the norm. Information was asked for, and it was not provided.

numbers entered and the number output make no sense together

The first number entered is the count of the numbers. They don't indicate that with a prompt or anything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i can just include a welcome speech at the end of my post.

Put it in your signature. "If you're new, welcome, if you're returning, welcome back, and if you're here all the time, you're WaltP" :)

jingda commented: Nice one +0
WaltP commented: Ouch, my side hurts :-P +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, with your first vector as the first row, and your second vector as the second row.