jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

you can use the /t and /n in your output

I believe he means '\t' (for tab) and '\n'

Go with what Moschops recommends (a related command is found http://www.cplusplus.com/reference/iostream/manipulators/setw/)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't understand what about "cond" makes it output the second line? (did you mean "second"?) How would you output the first?

You'll have to take in arguments from the command line (look up "argc and argv" for lots of examples).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't have any insights into your problem, but I'm curious about something. Doesn't the compiler complain on line 14 that lwFile isn't a const char * ? Normally the fstream objects take a C-string (so you'd need lwFile.c_str() in that spot instead).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're going to have to create a class that inherits from ListView and play with the underlying mechanics to get it to do what you want. Here's an example of doing it in VB (http://www.vbforums.com/archive/index.php/t-145805.html I know it's the wrong language, but that value that they cite is probably what needs to be modified). So, inherit the class and change the CreateParams property.

For example, this was a way to turn a horizontal scroll bar into a vertical one:

property System::Windows::Forms::CreateParams ^ CreateParams
   {
	virtual System::Windows::Forms::CreateParams ^ get() override
	{
            System::Windows::Forms::CreateParams ^ cp = ProgressBar::CreateParams;
	    cp->Style |=0x04;
	    return cp;
	}
   }

And then there's the freebie option, which is probably worth mentioning, if you don't need the gridlines you can shut them off. I don't know how feasible that is for your project.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For .NET it's honestly the best way to go. I saw that you had some threads over on C#. Good luck with it all.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

while(counter < months) I meant, sorry.
counter = 0, counter < months = true, loop continues
counter = 1, counter < months = true, loop continues
...
counter = months, counter < months = false, loop stops.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've got months and counter flipped around. Count up until you reach months, not the other way around.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, that's exactly it. The order in which you were doing it before was writing 0 to the variable (that you had passed in), taking input to write over the variable you had passed in. accountBal wasn't getting anything but the 0.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, I see what you mean, apologies that I misunderstood what you were questioning. I don't have a good answer yet, hehe.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Actually, you don't use the balance you are passing in anyway. Remove that parameter. Assign it to accountBal *after* the user enters it in. Now the object will carry the accountBal around (and you can access it from all of the other methods).

Vindal commented: Helpful and understanding. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A variable in a local scope with the same name as a global variable overshadows that variable. cows in farm1 is incremented locally but then destroyed when the function finishes. Try removing line 5 and see what happens.

P.S. It's considered a bad habit to use global variables (except in certain advanced techniques).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use a construct like this

cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );

(see the sticky thread on flushing the input stream for more details).

This will ignore a number of characters up until the maximum capacity of the buffer or until it hits a newline.

Since ans is a character, when you enter "adfsffef<enter>" the 'a' is written into ans and all the rest of it stays in the stream, so the loop executes once for each character and the newline.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look for libraries that support CMake, as that makes life much easier when setting things up to compile. The libraries will specify that they are compatible with it, or look for .cmake files in the main directory.

Otherwise, I don't know any specific libraries, but it looks like there's a wireless SDK for XP and Vista. Those are probably best used with Visual Studio, but I don't know that for sure.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Remove the =0.03 from the declaration (line 11).

balance is a parameter of enterAccountData(), so it goes out of scope once that method ends. Use accountBal in computeInterest() instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use ignore with no arguments, which will default to skipping 1 '\n' (you don't want the space like you have it)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

t=0 should be t==0 (the first assigns 0 to t, the second checks for equality), etc., but in this case since t is a double, it is tough to compare with 0 or 1, etc, due to the inexact representation of doubles. What does your data file look like?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There is a Python forum, I've flagged this to be moved there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just use the other version of getline:

getline(*streamReader,headerInfo);

string is simply a char array correct?

I'm not an expert on this sort of thing, but I think the std::string class code could be implementation dependent, so I don't know to what extent you can rely on it being a simple wrapper for a C-string. The above solution gets rid of the issue altogether.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In minus one day you can get negative day, and in function toname you only treat properly positive idx.

He's exactly right. What happens when idx is negative, your method toName runs right off of the end. At the end of toName, put something like return "junk"; . You'll hit there when you try to find the day before Monday. You'll have to catch that possibility.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was wondering if anyone could help me out on this library

Which library are you trying to use for the Bluetooth?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the range of numbers in your data set?

Make an array the size of your largest element. If you have 0-9, make an array of ints,"counts", that is size 10, and initialize each element to 0.

If you encounter a number, increment that digits place in the array (so if you encounter a 3, increment counts[3]. Then find the maximum of counts, that's your mode.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where is current resolution coming from, is that the size of your form's window? What do you want to happen to it (shrink if it's too big?) I don't mean to seem dense in asking you these questions, it's just I'm sure it's not a compiler bug, you've probably just got the ratios flipped over.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure I'm going to be able to help. Print out (I'm not sure how you do that in mysql) the columns of the row and the value of b to make sure you're not overstepping something when you're seeking. It looks like if you're reaching the point that's causing the error, that the DB is returning valid rows, so that's not a concern.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is there a line at which that is occurring?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's a very long piece of code to ask someone to go through. Try to narrow down a specific region where you think the problem is occurring (you have your loop with the menu at the top, try to figure out why control is not reaching that point again). Try to think of ways to refactor some of the parts of main() into functions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I've remained reticent on this issue because I have dealt with the original poster in the past. He knows I that became the most irate when he banged out a solution to a problem and pasted it into the box, usually leaving no explanation. He underestimates the fact that any one of us could have done the same thing, but those who have taken the route of trying to explain something are punished.

If you want to help someone, you have to try to solve their real problem.

I agree. I would say for the majority, most of these students seeking help have been given snippets and samples already in their classes, and they are not able to extrapolate what they know. If someone really and truly needs a complete concrete example, I might illustrate a portion of it, but I leave the incorporation of that into their example/homework up to them.

But that's hardly our fault.

I understand what you are trying to say, but at the same time, if you give a child a book of matches to play with, you can't say "I didn't know he would burn down the church." Obviously, the posters are not children, but if people are not given a chance to plagiarize, they can't.

It's basically a slap on the face of someone helping out to post the solution on the 2nd/3rd page of an ongoing discussion.

I can think of maybe one time that I was explaining something,someone else …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

ToolStripMenuItem has a "Tag" property (I think all of the controls do) which you could use to store the URL. Rather than generating an event handler for each new URL, make a generic one that navigates to the URL in the tag.

What is the nature of the error when you try to add it to MyMenuToolStripMenuItem (also, what is the type of that variable?)? You may have to add that to your ToolStrip as an additional step.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Oops, this may be out of date due to overlap...

No worries, I'm bound to have overlooked something.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

They are called at the time the object is created. They can be used to initialize member variables and/or allocate memory for them.

class MyClass
{
   private:
       int x,y;
   public:
       MyClass(int xin,int yin)
       {
            x = xin;
            y = yin; //there's a shortcut to doing this, look up initialization lists
       }

       MyClass()  //default constructor (no parameter)
       {
           x = 0;
           y = 0;
       }

      ~MyClass() //destructor
       {
             //nothing brewing here
       }

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

if i would've known the answer, i wouldn't had started the thread......

Me telling you the answer doesn't help you learn anything. I'm just asking you some follow up questions, I'm not expecting that you're going to know everything

If you include a destructor with nothing in the body of it (or when the compiler provides a default constructor), it doesn't do anything at all.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not when the program is started, but when the object is created.

How about the destructor for a class that doesn't do any memory allocation?

What happens when you don't specify a constructor for the class?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are some of your thoughts, then someone can either confirm them or make corrections.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In your function, you first allocate an array of M pointers to double (line 45), then line 55 allocates an array of N doubles for each of those pointers to double. In freeing you need to first free each of the arrays of N doubles (lines 30-33) and then finally free the memory associated with the M pointers to double on line 35.

If you free(a) before freeing all of the a's, the memory associated with each of the arrays of double is going to be leaked, as there's no way to free it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What did the ClientResolution return for values?

Also, that overload of Scale has been obsolete since before .NET 2.0 (according to MSDN) so you might want to try the overload that takes a SizeF object. I don't know if the results will be any better, but there must be some reason it was deprecated.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The code works but it did not make sense. The application still have a screen size or resolution problem.

You're going to have to elaborate on what you mean by those two statements.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try changing line 3 to ClientResolution = Screen::GetBounds(this->ClientRectangle); You need to give GetBounds a rectangle or a control so it can give you back the resolution of the screen showing that object, so give it the rectangle of the form.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

anyway check header file?
declared that string?
semicolon?

What would any of those have to do with the "skipping over" of the getline at runtime?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't have any experience with vtk. Some people that are around might, but I can't remember who they are. I haven't done anything in the way of animation either, so I can't help you with that either. Let the question hang around for a bit and see what the other replies will be.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you have a line like cin >> somevariable; up above that point? There's probably a stray newline left in the stream from where you pressed enter during the cin operation.

int i;
string str;
cin >> i; //enter in 10 + <enter>, 10 goes into i
getline(cin,str); //getline picks up enter ('\n') and thinks input is complete

See the sticky thread in this forum about flushing the input buffer. But, if it's just that one stray '\n' putting in a cin.ignore(); before your getline statement should do the trick.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Since you're not asking about C++ explicity, do you have access to Matlab? There is a command called quiver3 that might be exactly what you are seeking (http://www.mathworks.com/help/techdoc/ref/quiver3.html). It looks like octave might have something similar as an add on (http://octave.sourceforge.net/octave/function/quiver3.html).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I've never done COM, sorry. Hopefully someone else can pick this up for you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

unless reputation in this forum doesn't count

Nope. Hehe.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On line 61 do a strcpy instead to move it into the buffer. Right now you're concatenating a good string onto junk. Then concat onto the newly copied string.

It looks like strcat_s takes a size parameter like strcpy_s does, so did you use it with 3 arguments?

Also, since you're going to run into it anyway, look at the order in which you are adding the strings in 61 and 63. So, you'll want to strcpy the first one and strcat the second one.

L3gacy commented: thanks +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't apologize, just letting you know. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please post your current code with the changes.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try out the Mark Summerfield free one (http://www.qtrac.eu/marksummerfield.html, Qt4 version, first edition). It's not bad. The first few chapters he takes you through creating a "spreadsheet" application. That part may be too basic for your needs, but he then goes through the rest of the library (including all of the threads and sockets info). Again, it's probably one that didn't receive super high marks, but it's a good jumping off point, IMO.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I also get problems in receiving my mails after a member has posted a reply. I need to constantly refresh the pages where I had replies to see if there was any other replies added. This happened yesterday and the day before for a while, then all of a sudden I get a ton of mails that was about 3 posts late.

I'm not sure whether it's worth starting a new thread on, but I have not been getting any emails for the last 12-24 hours (over the last week, I've been missing some replies(I'm never sure whether or not that's DW's server or Hotmail), but almost everything was getting through ok).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are you expecting it to print? Can you narrow it down to a small section that's not working?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

hi
i think you have overloaded ">>" operator so that compiler gets confused about which operator should be matched exactly with that operand since >> is a built in operator so you should not overload it.
Hope this will clear your confusion...

Wait, what?

The issue is that your prototype for >> in your class declaration doesn't match what you have in your defintion.

friend istream& operator>>(istream& is, Rational[B]&[/B] r);

vs.

istream& operator>>(istream& is, Rational r)

To the compiler, those are two different signatures, one with a reference to a Rational and the other without. Just change the second to Rational & r Also, a minor point, the semicolons after your method definitions 46,52,58, etc., are extraneous (when compiled with a low warning level, they are passable, but conventionally they are not placed there).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You want a function like strcat instead of strcpy in that case (the M$ "safe" equivalent is http://msdn.microsoft.com/en-us/library/d45bbxx4(v=vs.80).aspx strcat_s.
strcpy by nature just clobbers whatever is there.