jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry, it should be whatever the name of your combobox is, systemBoxComboBox instead of systemBoxComboBoxMenu (I copy/pasted too far)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Change your event to systemBOXComboBoxMenuItem_Click to systemBOXComboBoxMenuItem_SelectedIndexChanged

systemText->Text = systemBOXComboBox->SelectedItem->ToString()

I need to look it up, but it seems like ->SelectedText does not work

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, but you can test it out for yourself, too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, so I'm asking you why you need the quotes on the string constant "Please enter the starting balance" and not on the string constant "credit." It's the same idea. You need them both. credit is a variable named credit, "credit" is a string constant equal to the word credit. You want to compare xact_type to "credit", not to credit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've got xact_type where it's supposed to be now, he was saying take it out of the variables you were declaring as floats. That's all squared away.

You're getting closer, but how do you write a string constant -->> " "
you didn't write

cout <<Please enter the starting balance;

so why would you write

xact_type == credit
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
if(xact_type == ???)

Why do you keep wanting to find out if it's equal to itself?? Of course it's equal to itself. You want to find out if it's equal to a certain string. See if it's equal to that string. Also, else doesn't need any expression with it. Else is what covers anything that doesn't fall under the other conditions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

#include <string> (you still don't have #include <iostream> listed in your code either). It's likely when you found string str; that "str" was a specific variable from someone's code. How would you declare any other variable that is of type XYZ? Nothing special for strings.

It's not good form to beg people to fix something for you. No one is going to give you the answer. In reality, you have all the answers you need to solve this, you just need to think about what you are doing and bring it all together.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

But still I need another answer.

Yup, he's right. Nick's been doing this for a "couple" of years. I'm confused as to what you need more answers about?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check line 36. I don't think it's the main problem, but it will catch up with you eventually.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 9 (second listing) should not look like that. Are you trying to call the function? It looks like a definition. Also, formatting your code with proper indentation would make it easier to spot errors with the braces. Lines 88-100 on the first listing seem like they are floating outside of any function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Assume Lucy’s stride length is 2.5 feet. Using the fact that there are 5280 feet in a mile, have your program display the average number of strides Lucy makes in a minute (a float) and the distance Lucy jogged in miles (a float)

You have still not even matched up your prompts with those in the example. Little details are important.

You have two constants that you have not defined anywhere. Also, does your program answer the question asked??

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

First, please use code tags [code] //code here [/code].

You've been given a sample output, and your code doesn't match. Try to get your program to produce those phrases verbatim. After that, try putting in all the input steps, and then add in the math. Do it in stages like Ancient Dragon recommended.

You're answering a different question with your code, so that would have to be addressed, too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay. The short answer to all of them is no. There are some different ways to get behavior that is similar. This thread on stack overflow talks about some of those things. http://stackoverflow.com/questions/9321/how-do-you-create-a-static-class-in-c.

To get a class that is not allowed instantiation, you need a pure virtual function to make that class abstract (see http://www.learncpp.com/cpp-tutorial/126-pure-virtual-functions-abstract-base-classes-and-interface-classes/ for a great explanation).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

5. Is this homework? ;)

Why don't you write out what you think the answers are and someone will check them over for you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your code is close. I had forgotten about DrawImage. You need to put it in a loop:

const int width = 80; //from your own picture
const int height = 80; 
const int multiplier = 5; //how many across and down
Image ^ picture = Image::FromFile("<your path here>");
Bitmap ^bmp = gcnew Bitmap(width*multiplier,height*multiplier);
Graphics ^ g = Graphics::FromImage(bmp);
for (int i = 0;i<height*multiplier;i+=height)
{
    for(int j = 0;j<width*multiplier;j+=width)
    {							
  	g->DrawImage(snake,(float)j,(float)i); //since x is width and y is height
    }
}

I only tested the code with a square image over a square area, so I may have something backwards, but you get the idea.

Then you can set a picturebox to hold bmp (and there should be no problem saving that out to a file, either). One thing to check, add a border to your picturebox for testing purposes. If nothing shows up in the window, you are probably missing the Controls.Add(yourpbox); call after you've set all of the parameters of the picture box.

if I had commands to delete the data from the Image and Bitmap files I opened at the last 5 lines of the function, like I did with the Filestream right above them, it would result in a GDI+ exception of an invalid parameter

That one I'm not sure of. Are you trying to clean up your objects? Unless you are seriously squeezed for resources, let the garbage collector take care of it. In terms of the exceptions, other objects may be relying …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can use an iterator for what you are trying to describe (see the second post of http://stackoverflow.com/questions/3221812/sum-of-elements-in-a-stdvector). Or you could use std::accumulate (http://www.cplusplus.com/reference/std/numeric/accumulate/ or the above link)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is the solution posted here (http://www.daniweb.com/forums/thread90228.html) as a tutorial by narue not the best way as it handles more situations consistently? and i dont see that her code would not be portable?

Anyway many thanks for the feedback

I'm definitely not saying Narue is wrong in that case.

You can certainly flush the stream before you call the cin.get() but a cin.ignore() will get rid of a stray '\n' that could be picked up by your cin.get().

In your code comment, it sounded to me like you wanted to put in a system("pause"); , and that's more what I was trying to dissuade you from.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
cin.get(); /* i know this is soo wrong and bad but im just lazy in small test appls to use proper pause code here or to pipe output to a file */

This is actually one of the most portable and safest methods of pausing.

Just wanted to comment on that, I have no insight into a more effective algorithm.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, the tiling is easier in a picturebox. I think you would be able to tile it on a picturebox (using the ImageLayout::Tile) then take the BackgroundImage as a new image and save it. I've never tried it like that, but it's worth a shot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you using Winforms or Win32? If Winforms, search on "GDI+ tiling an image" (some of the examples are for VB, but the syntax should be easy to translate to C++/CLI)

Are you trying to display it or do you need to save a copy out like that?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I meant more for you to show us what you tried with the passing by reference.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please post your current code with the changes you've made.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out line 8 of your original posting, your prototype says that it takes 3 arguments. Something must be changed so the number of parameters matches up in your prototype (line 8), your definition(line 63), and your function call (line 22).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Test whether letter.length() == 1 and while you're at it, check to make sure it's a valid letter using isalpha() from <cctype> (or your own version).

Can you not change the signature of the function to take a char?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

gcc 4.6 hasn't been released yet. I checked on http://gcc.gnu.org/gcc-4.6/ and there are no stable builds listed on that page. You'd have to get a nightly release (I don't know where to find those) of the prerelease code. I'm not sure what the status of the mingw (the Windows port of gcc) is for 4.6, but since it's even less likely to be ready, you'd probably have to build the Linux nightly build under MSYS (http://www.mingw.org/wiki/MSYS).

I would get the latest mingw release (v.4.5.2) which is simple enough to set up (there's an installer now for Windows) and use that with Code::Blocks. You won't get all of the experimental keywords from C++0x, but using that website that Moschops posted, you can see how many of them are already available.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In response to jonsca, the Mono project isn't as up to date as the Microsoft implementation of .net for obvious reasons but it does help.

Yes, after I'd written that I'd thought about looking into the extent that it was compatible, but got sidetracked. A very good point.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

@OP I didn't realize that the introduction of stuff was staggered like that, so unless you have the 4.6 my suggestion won't work. Apologies.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go into C::B and open up Settings/Compiler and Debugger Settings and select GNU GCC Compiler at the top (assuming you load up C::B on your laptop with the default compiler). Select the Compiler Settings tab, and go down about 9 entries to "Have g++ follow the coming C++0x ISO C++ language standard [-std=c++0x]." That should allow you to use the new stuff.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just select a "Win32 console project" to do "regular" C++. The alternative to .NET is using a "Win32 project," where you can use the Win32 API (see http://www.winprog.org/tutorial/ for an excellent intro to the subject). There's a steeper learning curve for the Win32API, but it brings you much closer to the OS.

I would at least take a look at some benchmarks before denouncing it completely, Mike. Intuitively, it feels like it should be slow as molasses, but in practice the JIT compilation can actually make it faster (see http://stackoverflow.com/questions/1500584/performance-difference-between-c-and-c-for-mathematics).

not portable

Not true anymore. Mono Project?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Again, I'm not an expert, but I think you should have clarified it was a CGI that you wanted to run, not strictly a C program. I think that CGIs had their heyday in the 90s, but have given way to Javascript on the client side interacting with PHP on the server side. This may be a question more for the web development folks. If you think that's the case, hit the "Flag Bad Post" under your name and ask for the thread to be moved to another forum of your choosing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have to add it to the tabPage of the tabControl directly. I hid the PB until I repositioned it to where it belongs. Other than that, what I replied with before should do the trick.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

malloc sets aside a block of memory, it does nothing to initialize it whatsoever. You get whatever happens to be sitting there. You could possibly use memset to blank the char arrays out (I do not know enough about how it behaves or if there are any side effects/gotchas associated with that). I'd say just put a guard in place to prevent the user from displaying the data before there are data to be displayed if you are concerned about it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay. My sentiment is still the same, though, you can't display what you haven't put in yet... What do you expect will happen when you do that? (maybe I'm missing something here)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, if you haven't added any records in, then don't try to display them. You've discovered that when you declare a variable in C, there could be any junk at all in it. You could add something to your code to make sure that there are records before you display them.

Also, why is the menu in that screenshot different than the one in your code?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I ran your code as is and entered 3 students worth of data in step 1, and then went to step 3 and the data displayed as I had entered them. What does your output look like (you can paste it right in with code tags).

I don't think this is the root of it, but you might want to consider converting your scanf statements for the strings into fgets statements, that way your user can't input something that will overrun the char array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It might help to know what you are trying to accomplish, unless this is just an exercise in theory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

scanf has a return value which will tell you how many items were successfully converted (it returns EOF if no input is given). Use that in the condition of a small loop around lines 9-11.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

LOL okay. I'll give it a test if I have a chance.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Declare a picture box, set it's coordinates and background image (and the background image layout). Once that's all done, use the .Add() method of the tab control to place it on the form (I think the default is visible, so you don't have to set that before adding it). See if that works, otherwise I'll put together an example to refresh my memory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a look at this: http://www.cs.tut.fi/~jkorpela/forms/cgic.html Common Gateway Interface is the name for this sort of thing (Colby even calls it that on the websiste). That link goes into some of the technical aspects of it, but it seems if you can find hosting that will run CGI scripts then you should be okay. I don't know if it's correct, but it looks like in that link they compiled the C program to an .exe and simply renamed it .cgi.

Under the software/development tools table further down on that server company page it lists "Full Cgi-Bin Support." You may want to check with them, but that's probably what you're looking for.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It wouldn't change much of your code at all to put in the do/while loop

do {
/*all of your code from 8 to 22 */
} while(choice == 'y' || choice == 'Y');

then eliminate 23-25.

Calling main like you did is technically recursion. It's not forbidden, but be aware that each time main() would be called from itself, the "state" of each call to main would be conserved on the stack as another instance of it was called. Those representations (address/instruction to return to, and I think local variables, but I'm not sure) could pile up ad infinitum or potentially until it crashed your program.

Looking something like (but don't quote me on the specifics -- take a look at http://en.wikipedia.org/wiki/Call_stack for a good overall explanation):

[n-th call to main()]
   .... 
[3rd call to main()]
[2nd call to main()]
[1st call to main()]

I read up a bit on it, and it seems how you had it set up was a "tail" recursion, which the compiler can optimize away if possible. Doubtless someone knows whether or not this type of thing is allowable under the different standards (C89. C99, etc.), but I wasn't able to find any clear cut statement on that. I do know it's non-standard in C++, but that has no bearing on C per se.

The bottom line is that a simple do/while avoids all of this potential headache. I am not sure about your book's statement about …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also, you're now using the C function

I think this belongs in C, I flagged it for a mod.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have you covered scanf in class? (arguably you should use a fgets/sscanf pair, but I don't know if you've learned those yet)

Read in an integer value using scanf(call it n_user or something) and replace that hard coded 5 that you have there with n_user.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure if this configuration is dictated by your assignment, but, in my opinion, I think your circle class should have a point member ("composition") instead of deriving from the point class. What you are seeking is more of "has-a" relationship ("a circle has a point(center)") instead of an "is-a" relationship ("a circle is a point"-doesn't really fit). I realize the is-a/has-a suffers from some limitations, so that's why I'm presenting it as an opinion.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Oh, it's just a string to temporarily hold the string at the front of the queue, since he's putting the elements into a new queue he created (which was not a copy, but just an empty queue) -- once the first element is popped off of the original queue, it is lost.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Based on your original post and griswolf's explanation you should know how to show all of the members. Give it a try first, knowing that copyq is an exact copy of your original queue.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just like when you declare an object and copy in another.

Queue<string> copyq(myqueue);

or call it Bob or something.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please use code tags [code] /*code goes here*/ [/code]

You shouldn't call main() like that, but the real problem is the semicolon at the end of your if statement if (choice=='y' etc) . If the if statement is true, the then "statement" is ; and then the program continues with the next line.

Read a little ahead in your book to the do/while statement section and replace your call to main() with that.

One final thing, when dividing 2 integers you're going to lose the decimal information. Also, try putting in a fraction like 5/7 and see what happens.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

(Copy queue to another name, show next, pop.)

That's essentially what I was saying to do. I'm unsure of what your hesitation is.
(I forgot that pop() doesn't return the value of the popped object, so showing then popping is the way to go, sorry)

id also like to apologize if i seem a little curt.

No worries.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's the catch-22, you can't view all the members and keep them in their place in the queue (as griswolf pointed out). That's the crux of the datastructure. I like griswolf's idea, or along those same lines, pop them out and push them right back onto the queue until the first element is first in line again.