jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you have the first option selected (option 0) it returns 0 (total +12), second option (option 1) it returns 1 (total +13). Chaeldar would add a total of 12. Just make a form with a combobox on it and play around with it a little. You don't need the if statement like you have it because the box is agnostic to the actual contents, as long as you keep everything in the right order it's fine.

but does this apply to a specific option or all options in the combobox?

Every option has an index associated with it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For the rest I have absolutely no idea. In fact, you didn't mention from which language you are translating this code. In what programming language is the code you posted? I cannot tell and have no idea what the "=>" syntax is supposed to mean (maybe equivalent to "->" in C++, just as a guess).

The => symbols are found in lambda expressions in C#
(ex using a C# count operator int oddNumbers = numbers.Count(n => n % 2 == 1); ) n is basically an anonymous function.

All of these SelectMany() and Select() are LINQ (language integrated query) methods and you'd have to implement those by hand (doubtless that there are algorithms out there used in SQL connectors). You could probably get away with treating some of your data like a database and running similar operations from a SQL library.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You want something along these lines

int tb1value;
Int32::TryParse(textBox1->Text,tb1value); //enclose this in an if to make your own error handling
int tb2value = tb1value+comboBox1->SelectedIndex+12; 
//it doesn't matter what's in the box, just use the offset
textBox2->Text = tb2value.ToString();
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think it's Ctrl-D on those systems, actually.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
gets(path1);

You can overrun your buffer with gets. Use fgets instead (or you can use cin.getline if you want to use the C++ standard library).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Except that if the value is not found the newValue would be set to the default value for a particular type (0 for ints, false for bools, null for objects) see: http://msdn.microsoft.com/en-us/library/zkw5c9ak(v=vs.80).aspx

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you looking for a specific ordering like 000-111-2222 ? If that's the case you might want to try a masked text box. There is a current thread in C# on this (http://www.daniweb.com/forums/post1440491.html#post1440491) (I know it's not the right language, but it's the same .NET library, so you'd just have to translate it into C++ syntax).

If that's not what you need, post back and we can help you figure out what you need.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Usually anything with Try in front of it in C# checks to see if the retrieval/conversion/etc. is valid so you can use the call in an if statement.

Since the bool is returned, the value is returned by reference in the second parameter (C# has the designation of "out" to indicate that the parameter will be given a value within the method call). You can modify ravenous's code slightly to attain the same features.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you are on a different platform than he is (Linux vs. Windows) you're going to have to compile his code on a Windows machine. He could conceivably generate a Windows binary, but it's not the default and it's probably too much trouble at this point. have him send you the .c file. As long as there's all standard functions it should compile on both platforms.

EDIT: Vernon beat me to it. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On the left hand side of your post (the post in question, not this one), underneath your name, hit the "Flag Bad Post" button and explain your situation to a moderator.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you are using C++/CLI like you were, a String ^ has an identical ->Split method to the one in C# (since it's all .NET). I think it requires a cli::array<String ^> to accept the pieces.

I suppose you could use a stringstream, but you'd have to convert your String ^ to a std::string by marshaling.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Some of the banned users still seem to appear in the "Currently Online" and move up the activity points chart. Is it that they never logged off?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

a nice green blocky of +rep

I miss the green blockies...

I said this in A51 but it's worth mentioning again that I have yet to encounter any of this nefariousness, so yizzles are doing a kick-azz job with it. Anytime I've spotted anything on the activity points radar (and I check because I've been edged out by that Adatapost fellow, curses) the parties have already been banned.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So per the assignment, your function should return nothing and therefore be void. You are still not getting that you need a parameter for your function. Look for an example in your text that takes an int. Where is the int in your function definition? Forget about the contents of the function for now, just set up the skeleton of it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Getting closer. Line 8 is better, but you still need an integer parameter. I would revert line 19 back to being an int so you can pass it into your function.

A function definition looks like:

[I]Returnvalue[/I] functioname([I]datatyp[/I]e parameter1,[I]datatype[/I] parameter2, etc) { }
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Since your numbers are integers, you need an integer parameter for your function. Have it return a std::string.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This should give you the information that you need: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx (scroll down to the example)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 79 of your first listing you have a semicolon after the if statement.

Also, remember than in C++/CLI the . operator of C# can translate to a namespace or a member function. (so either a :: or a -> or even a . for a non-pointer)

But, AD is right in that you need to find the equivalent for a console application (I'm not sure if selecting CLR console will allow you to access the System::Windows::Forms members, but there should be an alternative).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

To make your code neater you can hit enter(just not in the middle of your strings), like:

cout<<"According to my calculations...if you were to buy..."
    <<userinput[0]<<" cars for $"
    <<userinput[1];

as the compiler will get rid of the whitespace.

The nice thing about cout is that you can simply keep giving it input without an "endl" or a "\n" and it will keep it on the same line.

cout<<"According...";
cout<<userinput[0];
cout<<" yada yada"
cout<<endl;

and it will be all on one line too. Experiment with it a little.

As far as your second problem, you probably have a second cpp file in your project called whatevermyprojnameis.cpp, which contains a main() by default. Go ahead and either omit that file from your project, or delete the code that's put in there by default.

Nick Evan commented: Solved all problems in 1 post. Nice :) +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's still pretty much the same issue. I'd leave a link to this post at the end of your other one so people don't keep responding to it.

I've been looking around in the meantime, did you ever see this link http://www.dotnet247.com/247reference/msgs/25/129971.aspx (note their change to the method ending in "uni" in the second post). I think this is just one of those vexing things that arises with managed vs. unmanaged code (with all of the marshalling of pointers, etc. that has to go on).

Surely someone in the past used mci under C++/CLI, but those must be the people asking the question on the other boards.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How is this any different than your other thread?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Glad you figured it out. I tried reinventing the Point class, but I wasn't reproducing the problem.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I've seen the so-called obfuscators (google "C++ obfuscator") but I can't speak to their validity or effectiveness. A few I saw changed strings to their hex equivalent, but that will only get you so far.

Is there a connection string you don't want your end users to see? I think the nature of the data will define how it can best be hidden.

.It. commented: Good answer. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When i and j are 0, index = -width, which is incorrect. For the row 1 (the second row) you want width*1 + j (offset of 1 row + the column offset).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The compiler is not generating a default constructor for your struct. I'm not absolutely sure why, so I won't speculate and steer you in the wrong direction. Where does Point come from?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

for ( WordsToAnalyze; WordsToAnalyze[StringPointer] != ' '; ++StringPointer) You went back to this again, and the syntax is not correct.

I agree with WaltP, put some debugging code in there to see what's in each of your arrays at any given time (simply print them out character by character).

Don't get mired down by one exercise so much that you give up your quest, though. It never hurts to take a step back and look at the big picture, IMO.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need a prototype for your method (I tend to reserve function for procedural programming) in the header file like: int AnyFunction(); under the "public:" section.

and

int clsHelloWorld::AnyFunction()
{
    return 1;
}

in the .cpp file.

I think the equivalent of a procedure in C++ would be a method "returning" void.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think we overlapped. That wasn't in response to what you said. What do you mean by a procedure?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I know it's not exactly what you are looking for, but see if you can adapt it (I don't want to take away all your fun!)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

To have your class interact with the form, you need to send in an instance of the form:

public ref class ClassData
	{
	private:
		System::Windows::Forms::Form ^ frm1;
	public:
		ClassData(void);
		ClassData(System::Windows::Forms::Form ^ frm1);
		void ChangeButtonText();
	};

Then declare an object of the class in the private variables section of Form1.h: ClassData ^ Cd; . Instantiate it in your Form1 constructor or wherever, passing in the form as "this". Then use it as you would any other object (so you can call Cd->ChangeButtonText();

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm assuming you selected a CLR/Winforms application in VC++. If you want to make a standard C++ program select Win32 Console Application instead. The CLR implementation of C++ (C++/CLI) relies on the .NET libraries and a slightly different syntax (as you're finding with the "ref class" keyword. There are a few good sites out there like http://www.functionx.com/vccli/index.htm but honestly if you want to do .NET programming and you're just starting again you're probably better off with C#, IMHO.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why not make some arrays of Card objects? You could have 3 arrays (or lists or vectors, etc.), one for the deck, one for the hand of the player, and one for the active meld. I know you've done some work on this already, so those are just suggestions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Actually, another thing that I did was append a space after the last word of the input buffer, as if you type "done" and it's not followed by a space, the loop will run over the end, as WaltP has pointed out. I had brought this up a while back, but I think it got lost in the shuffle.

You can scan along your buffer and find the last letter and drop the space in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The statement after the comma on line 30 does nothing, but you're onto the right idea. You need to add a null terminator onto wordAnalyzer. Then you can skip the strcpy and compare it directly. I don't think that strcpy will append a null character if the originating string doesn't have one, but I'm not intimately familiar with the <cstring> functions (I know for a fact that it does copy over the null character if one is present).

The only difference between your code and mine was that I appended the null character and did not go through the strcpy step.

Honestly, I think if you've come away with some appreciation for the character array as a basis for C-strings (and later you can compare them to std::strings) and understand why they are manipulated the way that they are, then you're probably fine.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Under Project/Properties/ConfigurationProperties/Debugging/CommandArguments

Tellalca commented: Thank you, that helped! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I believe the switch is "-E" to preprocess but not compile.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why not just save it in a string and carry it along? I'm not sure that information sticks with the pictureBox (MSDN says that there is metadata available, but I don't know if that includes file name or not). Worst case you could make your own pictureBox that inherits everything else and includes a filename property.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you trying to get the filename back from something you've assigned earlier to the BackgroundImage property?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Choose an x from the range of x, chose a y from the range of y, choose x1 from the range of x, choose y1 from the range of ys.

If list[x][y] or list[x1][y1] is 0, neither is swapped and a new set of x,y,x1,y1 is chosen.
Else, swap list[x][y] and list[x1][y1] and pick a new set of x,y,x1,y1

It's not as random as can be, but it should suffice for your assignment.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry, I thought you meant
x1
y1
x2
y2

What are the data types of all of the variables?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

"%f \t%f\n" says print a space, the first value, a space, then a tab, then the second value, then a newline.

You need to put a newline in between the first and second rather than a tab.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Maybe what you're looking for is:

int* list = new int[Width][Height];

Did you try that in the compiler? It doesn't work. For a dynamic nthDimensional array you have to build it up.

[rows,columns]

int ** my2Darr = new int*[rows];
for (int i = 0;i<rows;i++)
     my2Darr[i] = new int[columns]; //for each element of the row array, make a column array
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The number zero cannot be shuffle.

Can you clarify what you mean by that?

It's not perfectly random by any stretch, but the easiest would be to choose a row and choose a column, check if that element's already in the list, if not add it, if so, choose a new row and column. I understand what you are trying to do, but I don't think it's the best approach.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's a compiler flag you can set for C in Visual Studio. Go to Project/Properties/ConfigurationProperties/CC++/Advanced/CompileAs, and switch to C.

shadowscape commented: you are awesome, thanks alot for all your help, it means alot to me +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For certain, you don't need the semicolons after the if statement on 48,50, etc., just the one after return 0; The reason the identifiers are undeclared is that you are compiling the code as C89 code, which requires all variables to be declared at the top of a block.

If you'd rather this be in C, hit the "Flag Bad Post" button underneath your name and ask a moderator to do so.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think that i is incremented in the while loop, line 111.

I think you're right! Sorry.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're passing choice by value to the function menu() , I think that you should use:

menu(&choice);

The OP has passed the correct way. He's not after a pointer, it was a reference variable.

@OP: What are you expecting your function to return? You pass in your arrays by pointer but repeatedly write to the first element. You need to increment i somewhere.