jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go to the "Compiling" link at the top of the page you linked above. It looks like it requires the windows multimedia library. I'm not familiar with it, so google around and see, but you might only have to add winmm.dll to the dependencies (under Linker/Input under all of the Project/<yourproject>Properties).

Beyond that Compiling page, the authors might be able to help you via email...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look into a DateTime object: http://msdn.microsoft.com/en-us/library/system.datetime_members(v=VS.90).aspx

Create an instance of a DateTime object and set it equal to DateTime::Now, then just use the hours, minutes, seconds members to get what you need.

If you want it to update every second, use a Timer object.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The conversion wizard didn't pop up? Try opening the .sln file from within Visual C++ instead of by double clicking it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is your assignment to write the solver or simply to solve that set of equations?

If it's the latter, just use http://www.mathworks.com/help/techdoc/ref/rref.html, it's essentially doing the same thing by a slightly different method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Unarchive it to a directory. There's a MSW directory that contains a VS project. Open that up and build it. Check the lib directory for the lib files (it probably does a debug build initially, so you may have to do a release build later).

After that's all built, go under Project/<projectname>Properties/Configuration Properties/CC++/Additional Include Directories and enter in the directory where the header files for the library are.

Then also under Configuration Properties/Linker/General/Additional Library Directories enter in the location of the lib directory.

Then under Configuration Properties/Linker/Input/Additional dependencies put the name(s) of the lib files in the lib directory.

The first part is specific to this particular library, but the last 3 steps apply to any library.

Give that a go and see if you have any more problems.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I hate to tell you this, but you're going to have to narrow the code down dramatically and present questions about specific sections because someone is not going to go through and check all those steps for you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're going to have to write out the error messages because most people don't know the error codes off the top of their heads.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was just playing around with it, but in case you're interested http://www.codeproject.com/KB/cs/DraggableForm.aspx also works (you need to change the Point * (as it's old) to regular Points to get it to play nice.

Glad you found a solution

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure what to tell you, this is one of those things that is difficult to diagnose, as it's some setting that you are selecting. Zip up and attach the directory of the project to your post.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See the example on the bottom of this page http://www.cplusplus.com/reference/stl/vector/erase/. You'll have to add an offset to .begin() to index in. So to erase the 6th element vectorGameList.erase(vectorGameList.begin()+5);

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i suspected it did not produce the warning you are seeing,...

I would say try starting a new project and copy your files into it (or you could try turning off multibyte characters under Project/<Projectname> Properties/Configuration Properties/Character Set and setting it back to Unicode, but I'm not sure if that will work).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, cout can handle C-strings okay. Hmm, when I compiled and ran it, it had no problem (though I didn't try it in Visual C++). What parameters are you giving your executable, and are you putting them in at the command line directly or via the arguments option in VC++?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Allocates room for a C-string in pFilename that's the length of argv[1] and room for the null character. Then it copies argv[1] to pFilename.

Is the above the exact code that you are using. If it isn't post exactly what you are running now.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Because argv is a C-string, you have to use the methods in <cstring> (such as strcpy, strcmp)


char * pFilename = new char[strlen(argv[1])+1]; //room for null terminus '\0'
strcpy(pFilename,argv[1]);
//accomplishes what line 23 does
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You are on the right track, but here's some more pseudocode

IF (it is a digit and we have encountered a space already)
   Keep a counter of the number of digits we have passed over

ELSE IF (it is a letter or otherwise)
   Turn off the flag saying we encountered a space
   Go back through the loop   

ELSE IF (it is a space and we have already encountered one)
   Back up the number of digits in the count and overwrite

Since the last character of the string could be a number or letter (or space really, but that should be taken care of), check for this outside of the loop and use the digit counter to go back accordingly.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The numbers you are looking for are surrounded by spaces (or in the last case by space and the end of the string). If you hit a space and the next digit is a number, start converting until you hit another space(or the end of the string).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

getting it to calculate the 750 pieces of gold

Where in your program is it doing that?

Also, I didn't have any problem with getting a figure for remaining explorers (except you did not pad your strings with a space, it just gets jammed in there).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please put some code tags on your post. There's still time to edit. Click the Edit button underneath your name and surround your code by [code] //code here [/code].

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's not lame, everyone is still learning something or other... :)

Lists are not too hard to add to your repertoire, and they are very useful when you don't know how many items you have.

List<string> sl = new List<string>();
sl.Add("first");
sl.Add("second");
sl.Add("third");

//sl[0] gives you "first"
//sl[1] gives you "second"
//sl[2] gives you "third"

You can make a list of your structs,too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

gcc refers to the GNU compiler collection (it's also the command to invoke the C compiler, which makes it a bit confusing).

Glad you got it working! (look into some of the other switches available with that compiler, particularly -Wall to have it display the highest level of warnings.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

- Compiling in Terminal

What is the command you are using to compile? You need to put both .cpp files in the command. g++ myclass.cpp mymain.cpp -o myprogram (assuming you're using gcc).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

anyone here?

Please have some patience, the person who ultimately answers you question may be sleeping now.

Have you run this function through a debugger to see exactly when it crashes?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Start looking into vector ok?

There's no need to store any of the values here, the OP just needs to keep track of a count.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure what you are asking.

The situation is, if you are taking the time to load up your array in this function, you'd be returning one element (which isn't a valid element anyway, firstly because your for loop goes up to and including SIZE, and secondly, because the loop is going to increment i one last time before testing it) which is two past the end.

If you are asking if you can return a whole array, you really can't. You can have your function return a pointer to an array, but it's much easier just to pass in your array as a parameter (as you are doing) and use the changed array in main after you have called the function.

void fillarray(int arr[],int size)
{
    for (int i = 0;i<size;i++)
    {
        arr[i] = i;
    }
}

int main()
{
   const int size = 10;
   int testarr[size];
   
 
   fillarray(testarr,size);
   //now testarr has "changed"
   for(int i = 0;i<size;i++)
   {
       std::cout<<testarr[i]<<" ";
   }
   std::cout<<std::endl;
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you are doing plain C++, you should select a project of type Win32 Console application, rather than a CLR/console. Otherwise it's going to be more of a hodgepodge than necessary (unless you are really looking for that functionality).

Check the "number" to see if it's less than 20 (using the if statement like you said) and increment a counter (an integer variable that you initialize to 0 before using it).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 21, just pass in matScores not matScores (which incidently, matScores refers to the (non-existent) element one past the end of the array).

Also, main should always return an int, according to the standard. void main may "work" in your compiler, but it will likely not work on a compiler that abides by the standard.

On line 43, you're only returning a single element of the array. You are changing matScores by pointer anyway, so your function doesn't need to return anything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is the number of test scores something that you can prompt the user for? If so, use a dynamic array:

std::cin >> numscores;
int * scorearray = new int[numscores];
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just to throw this out there: what if you read all the data for one car into a List<string> and added that to a List<List<string>>?

Add the first member of each list (the VIN) to the combobox, then use the SelectedIndex of the combobox as your index into the List<List<>> and display the make, model, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Make sure the textbox is set to multiline.

To append your text to what is in the box, use the += operator.
In your loop: (obviously read the line of text into a temporary if you're using .ReadLine() to drive the loop)

myTextBox.Text +=(myStreamReader.ReadLine()+"\r\n");

I didn't test that out, but that's the gist of it

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So that 'AC' becomes (('A' - 'A' + 1) * 10) + ('C' - 'A' + 1) which is 10 + 3 = 13

Except that AC is actually 29 (after Z comes AA, AB, AC, etc.), so for AA to be 27, A has to be 1 (you'd have to shift everything down by 1 to get a zero based index).

One way to make your life a little easier is to turn on the "R1C1 reference style" (I have it under Excel Options/Formulas/Working with Formulas in Excel 2007. This will give you a (1-based) column designation for each cell.

Ancient Dragon commented: I knew that, I was just testing you :) +36
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Glancing through, it didn't seem like anyone has pointed out to you yet that

if (200 <= sales[i] <= 299)

should be

if(sales[i] >=200 && sales[i] <=299)

The first version may compile as a statement, but it isn't going to resolve properly. The same for your other else ifs.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It has to evaluate foo() in the second case because if foo conceivably returns 0, then the second operand will have to be evaluated. I don't know if the compiler can think three steps ahead to know that that is not possible based on the values, but that might be asking a lot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is a good thread on SO about it: http://stackoverflow.com/questions/628526/is-short-circuiting-boolean-operators-mandated-in-c-c-and-evaluation-order

Both are short circuiting, so since your first operand of || was true, it skipped the foo() call in the first example.

VernonDozier commented: Good link. +13
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This int getMetaData( int dataFlags[], int dataSize); is making another prototype of your function in main, and (I believe) overshadowing your prior definition of it). Go back and look over your text as to how to call a function properly (hint, you don't need the data types in the call -- you do in the function definition and prototype, though -- and there's one other change you need to make to your call)

Were that to have been a correct call, your parameters for the function are declared after you were trying to call it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

> Egad! Steady on.
You realize I was joking, right?

I was offended and I'm not even Australian (at least I hope not) ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You are simply outputting your variable total (which hasn't been changed from when you initialized it) plus the ticket price. You need something like total+=ticketprice; . You want to do this if the seat is not reserved, so you can put it under an else branch of your if(s1==reserved) block (obviously, do the same for s2 and s3).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you have set the image as a PictureBox Image using the properties window, you just change the image in your MouseEnter handler. You'll need a MouseLeave handler setting the picture back to what it was if you want that effect.

In the MouseEnter: yourPictureBoxNameHere->Image = Image::FromFile(YourNewImagePathString); In the MouseLeave: yourPictureBoxNameHere->Image = Image::FromFile(YourOriginalImagePathString); I'm not sure what the big deal was, you were 3/4 of the way there. I was suggesting you use the BackgroundImage property (which can be set in the Properties window just like the Image property can) because there's more control over how the image is placed. I did it your way with the Image and the picturebox came out scaled funny (I'm sure there's a way to change this with Image, but I was offering you a suggestion I was familiar with).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're not returning anything in your function, which is supposed to return an int, so any information in c_charg is lost.

Also, where does area come from? You need to declare this in the function and calculate it with the length and width that are being passed into the function.

Finally, look at the calculation for c_charg - you're multiplying 8.23 times a quantity and trying to store it in an int. The value will be truncated into an int, and anything after the decimal point will be lost.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Keep a running total in a double variable. Add the ticket price into that total within each of the cases of the switch statement, like right after you set the seat to reserved (note that you want to make sure that you're only charging once per ticket).

In other words, add a else if condition to your if statement that says if the seat is unreserved, reserve it, and then add the price into the total.

Give that a try and post back.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Purely based on the C/C++/C# forums, nothing drastic yet, honestly.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, it certainly requires code to change the picture. Did you put the picture in through the properties window on the right side of the IDE?

I think you're misinterpreting background image here. I'm not talking about the Windows background, I'm talking about the image that is displayed in the picture box. I've never had any luck using the PictureBox.Image in this fashion, that's why I'm recommending setting and changing the backgroundimage of the picturebox, not whatever you have for the background of your application or the Windows background.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Through what method have you placed the image in the picturebox? Show the code that you use to initialize it. I have found it is easiest to set the image as "BackgroundImage" of the picturebox and then change it by replacing that BackgroundImage with a new one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's choking on reading the true or false values. When reading a bool from a file it's looking for a 0 or (EDIT: only works for 1) a 1 as false and true.

Read in "true" or "false" from your file as a string and then convert it to boolean true or boolean false.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

the choice is declare as int...

choice is character

I said choice should be a character. In the OP's code it is not.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's the property of the PictureBox that you want to change. How have you set the image on the picturebox thusfar? Please read the link that I gave you or find a suitable tutorial on the subject.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Note that it's "endl" with an 'L'

Take in your X and Y (you can't read into a algebraic relation like X+Y), also note that "x" as an identifier is different from "X".

Do the program a step at a time. Firstly, make sure your include directive is complete (you're missing a ">"). main should return an int always, according to the standard. Make it so your program reads in the numbers and an option, and spits back "6 + 3" or whatever the user entered.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

He's using .NET (C++/CLI). OP, you should specify this (at least that you are using a Winforms project).

MSDN has great pages on all of the controls. You'll find that you need to change the BackgroundImage (and probably the BackgroundImageLayout). http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox(v=VS.100).aspx

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry everyone!

It's all good.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, "here you go" is not acceptable. One, you've probably overshot the OPs progress in his course by a couple miles and two, that is not a way to teach anyone anything -- how does handing him something help him learn?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm assuming you are required to use the c-strings?

Check out strtok http://www.cplusplus.com/reference/clibrary/cstring/strtok/ (using the comma as a delimiter)

Also, never use gets(), you can overrun the buffer by a mile and corrupt the neighboring memory. Use fgets instead so that there is a fixed buffer size.