jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I assume you are using Winforms? There's a property of the form called ClientRectangle. It contains the height and the width of the form. Using those values, do a calculation for where to place the upper left corner of the 2nd form.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
for(i=0; line[k]!='\0'[B]; temp[i][j]='\0'[/B], i++, k++)

I wouldn't worry about the part in bold, I was just saying that you should be aware that temp is filled with garbage when you declare it.

Do one more k increment after you've found a word (so after your j loop is complete) so you can skip the space. In conjunction with that, put a '\0' after your last character (since j increments one more time before the for loop test fails, put it at temp[j], but after the j loop)

Boy do I suck at this

You don't, so don't worry about it. Once you learn std::strings you can put these aside unless you need them. C-strings are important to understand, but there are library functions (in <cstring> that make things easier).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try printing out what's in temp to start with, there will be junk there, so you can't assume there will be a null in the space after your string. Edit: ^^^^ also what AD said.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

0 and '\0' are identical and can be used interchangealy, which one you use is only a matter of programming style.

Thanks AD, it took me a couple of little programs to convince myself. :) I'm not sure why that never sunk in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, it's no problem. The easiest way to show yourself what's going on is to print out the values of i,j,k at each step.

The issues are: once you get to the last word, you are looking for another space and there isn't one. Have your program look for != '\0' && !=' '. Also, you need to put a null after each string, so at temp[j+1] put '\0'. The last thing is, you need to increment k once more after you find a word so you can skip over the space.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is this http://www.codeproject.com/KB/cpp/DoubleBuffering.aspx something like what you are looking for? (I don't know much more than the term itself). I'm not sure the answer to your second question.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

main() is prototyped to return an int, but returns nothing.

Actually, that's ok according to the standard. A return of 0 is implied if none is specified.

Clinton Portis commented: learn = good +6
kernel>panic commented: Yes, agreed. +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, LOL show me an example of what you mean (not to take this OT, but it might be helpful to the OP also).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

@OP By the way, main always returns an int according to the standard

@seanbp

I believe you are correct, but when matching character for character, you probably need to use '\0'. I'll have to defer to a third party to referee. :)

Bear with me, I'm trying to come up with an example and not succeeding.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's one of those questions that definitely depends on the project you are working on, etc. To me, if you know one of Java, C, or C++ you shouldn't have any problem learning the others and switching between them, but again that's just my opinion. I don't know much about Python, but it too is widely used and those that use it seem to enjoy it.

kvprajapati commented: :) cool! and nice avatar too. +12
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would invest in a good book like Koenig and Moo's Accelerated C++ (among others). Books like this take the approach of teaching C++ from the ground up, starting you out with C++ (and the standard libraries) rather than techniques drawn from C. The idea of learning C first is becoming passé, I think.

http://www.cplusplus.com/ is a great site for references and tutorials.

Others will be able to give you their suggestions, so watch for more replies.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

NULL is not the right thing to be testing for, you want to test for '\0' instead.

seanbp is right, you want a space character, which is ' ' (single quotes)

However, in one of the cases you need to check to make sure the character is not equal to a space and is not equal to '\0'

Keep a separate "word" counter for each time you encounter a space, use that as your first index of your temp array.

Also, make sure that you append a null terminus ('\0') at the end of each word, otherwise you're going to get garbage when you cout the values -- you accounted for it in your array size but didn't do it in your code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you place your cin statement at the top of the loop, you'll get it to run once entering the loop, and then it will run first and each subsequent time through the loop. To convince yourself, try putting a cout statement in the same place and see how often it gets printed.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, what we have described to you will fulfill the requirements of the assignment. Which part are you still stuck on?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where did the number 100 come from in the first place? Your best bet is a do/while loop.

If the number is not zero, the while condition will be true, and the program will loop again. Putting it in the do/while form guarantees that the program will prompt for the number at least once.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The semicolons on lines 13 and 22 don't belong there. If you put them there, the if statement will execute the statement with which you intended it to be associated regardless of the condition.

if(lotterynumbers == "123456");   // <--- the ; is associated with the if
    NotifyUserOfWin();    //just a plain ol' statement, lotterynumbers could be "7"
                          //which makes the if statement false, but it gets executed anyway
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

== is used to test for equality, = is an assignment operator, also else doesn't take a condition, so it would just be:

if(PlayerTurn == true)
    //etc.
else
    //etc.

In fact, you could write it:

if(PlayerTurn)
    //etc.
else
    //etc.

because it's already a boolean variable.

Also, no ; after the else statement.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, I was thinking maybe something within the header if you had modified it. See if Mike's suggestion of moving things around works, then we can go from there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're missing a semicolon after using namespace std; If that's just a typo, look in stdAfx.h to make sure you aren't missing a semicolon in there instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which part is giving you the most trouble? Please post whatever code you have tried sofar...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Anyway, not trying to give you personally a hassle about it, just stuff I've picked up on here and trying to spread good information.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

System("pause") is still a bad idea (as you can see from some of the rep comments above) because all one have to do is substitute another program to do just about anything, call it "pause," and every run of your software could be contributing to the delinquency of minors.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah, sometimes you need the cin.ignore() (or the overload that will accept multiple characters up to a sentinel which can be '\n') (see http://www.cplusplus.com/reference/iostream/istream/ignore/)

#include<iostream>
using namespace std;

int main()
{
   int i;
   cout<<"Enter a number";
   cin>>i; //user enters an integer + presses Enter => '\n' left in the stream
   cout<<"The number is "<<i;
   cin.ignore();  //picks up '\n'
   cin.get();   //accepts keypress
   return 0;
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

cin.get() buys you a nice portable solution to the "pause" issue. Sometimes a cin.ignore() is required beforehand to clean up junk in the stream.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put your comboboxes into a groupbox. Give each of your comboboxes a unique label in the Tag property ("CB1", "CB2" etc is what I used).

Make a single SelectedIndexChanged method and hook it up to all of your comboboxes (in the Form1.Designer.Cs file), so treat it as if you had separate comboBox_SelectedIndexChanged methods, but make them look like: this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged); instead of having this.comboBox2_SelectedIndexChanged.

private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
      string selectedtag = (string)(sender as ComboBox).Tag;

      foreach (ComboBox cb in groupBox1.Controls)
      {
            if ((string)cb.Tag != selectedtag)
            {
                    cb.Items.Remove((sender as ComboBox).SelectedItem.ToString());
            }
        }
  }

The only drawback is once the entries are eliminated, they won't come back if deselected. You could have a reset button on there to reload all of the boxes at once.

I won't claim this is the most effective method, so I'm sure someone can improve upon it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think that it gives that error message when you try to run a project that's not compiled. Click the little hammer icon or select build from the menu. Failing that, reinstall like griswolf is saying.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Great going, and thanks for posting what you found for others. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was able to get the drag entered and drag over to work (but not at the same time). I found this article helpful http://www.codeproject.com/KB/mcpp/DirectoryList.aspx.
I got the following line of code from that article, but I don't know if it's the right idea if(e->Data->GetDataPresent(DataFormats::FileDrop)) //do whatever One thing you want to check is whether you have the "AllowDrop" property (select the form and go to the properties window on the right) set to True.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In the designer, drag a button onto your form. Double click it, which will put an event handler in your code automatically. If there isn't a textbox already, then add one and make a note of it's name by looking in the properties window on the right side.
(let's assume the textbox's name is textBox1.


To start off, in that event handler that the ide generated type something like MessageBox::Show(textBox1->Text);

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does the code look like in MainScreen_DragDrop, MainScreen_DragEnter, and MainScreen_DragOver?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If your textbox is named textBox1, the textBox1->Text member contains the text that was typed in. Place a button on your form and double click it, and type your code in the button handler to display it in a message box or whatnot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put a } after the default case.

You also need to rearrange your loop so that it encompasses from cin >> Answer all the way down to the end of your switch block. Just prompting the user like you did won't loop back to the beginning.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Count your braces, you never closed the switch block off.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah, I made an edit, sorry.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to #include <string> but more importantly, you must pull line 80 out of the scope of the if -- since it's declared within the braces, it goes out of scope when that block ends. Move it to line 72 or before.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're going to need a library, there are no standard C++ methods for this. See http://www.mega-nerd.com/libsndfile/ I have never used it, but I'm willing to bet that a few people around here have.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes there is. It's a class, not a namespace, so you have to qualify the calls to the static methods with Math, e.g., Math.abs() or whatever.

vedro-compota commented: +++++++ +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Lol, the eyes went from the header to the included headers of the main file. Good catch. There's also a "this" pointer that's being used improperly.

I think that object (once the pointer notation is added) should be reigned into main() for safekeeping.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the filename of the first listing of code? It should probably be something like seat.h. Then you can change line 4 of the second listing to #include "seat.h" I understand what you were trying to do, but the < > signify to the compiler that you want to search a certain set of paths for the file (normally the includes folder, etc.). Here's a guide to the paths that the gcc uses in *nix http://www.mingw.org/wiki/IncludePathHOWTO. It will be different under Windows, as you can imagine.

Also, a side note, main always returns an int.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i'm holding my breath!

Don't do it for too long, you'll turn blue and faint.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I strongly suggest that you enlarge "dataType".

I think you're right on about that. I had thought about it, but I wasn't sure if the extraction operator put a null at the end of C-Strings. Evidently it does (which makes sense):


From: http://www.cplusplus.com/reference/iostream/istream/operator%3E%3E/

Extracts characters and stores them as a c-string (i.e. in succesive locations starting at location pointed by str and terminated by a null-character). Extraction ends when the next character is either a valid whitespace or a null character, or if the End-Of-File is reached.
The terminating null character is automatically appended after the extracted characters.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://support.microsoft.com/kb/955938 (change your button Click() event to a MouseClick() event). You still get the "flash" on the button if the user hits spacebar, but it doesn't do anything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you post up the entire data file? I want to see if I can reproduce the error? I was able to read in the row you provided with no problem.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does one line of the data file look like?

Somewhere you're trying to read something that doesn't match the type you have specified for it.

Just as an example, I know this is probably not the situation you're experiencing:

file:
1 pw 30.0 2.0

int i;
int j;
double x,y;

Infile >> i >> j >> x >> y; //doesn't know what to do with the pw, stops reading

Also, why not use an array for d1 through d10?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is probably what you are looking for: http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx (specifically the balloon tip portion and the balloon tip clicked event)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to explicitly cast the return-type to int ** , like int **m = (int **)malloc(r*sizeof(int *));

I think this is only necessary in C++, in C there is an implicit conversion.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
for (int i = 0;i<10;i++)
{
    std::cout << i;  //works
}

std::cout << i; //who?? doesn't work, i is destroyed once the loop ends.
int i = 0;

for(;i<10;i++)
{
   std::cout << i; //works
}

std::cout<< i;  //also works

Anytime you open up braces it's a new scope. I believe, but am not 100% sure, that the standard considers the statements in the parentheses of the for loop to be part of the loop body.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a look at the link I posted in my first reply. Try out some of the examples and then post back with any questions that you have. There's an overloaded << operator, so it's basically just opening the file and then using the operator like you would with cout.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Test it and see if it works, but yes, that looks correct.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 23 should be openagain >> k; but see http://www.daniweb.com/forums/post155265-18.html about using .eof()