jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What value does the durationString have?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

>> slechte ezel

Hahaha :) I suppose you meant "bad ass", but this translates as "incorrect donkey"

Yikes, it was worth a good laugh. Somehow I knew that was going to backfire on me. Blame Babelfish!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think Nick Evan has a steel-cased laptop with a Harley Davidson sticker on it and he uses it when takes a break from work to sit at a Dutch sidewalk cafe. He has a leather jacket with a patch on it that says "slechte ezel," (sorry, best I could do) and has one of those wristbands with the spikes.

Nick Evan commented: Lol :) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't type in your event handlers by hand, the IDE provides a mechanism. If you really want to do it by yourself, let the IDE do one and watch where it places the code. Go to the form designer, select your form. On the right hand side there is a window where it has all of the forms properties (title, etc). Click on the lightning bolt at the top of that window. Go down to Load and double click the cell to the right of it. You'll need to fill in the method that has been generated (or perhaps copy/paste the code from the one you generated by hand), but the handler code will be in the right spot in Form1.h.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The code that I had specified before would be in main().

ApplyFilter makes more sense (at least in my opinion) in the TheData class. Either make ApplyFilter take in a TheFilter object as a parameter (as I posited above) or have a TheFilter object as a private member of your TheData class. Make the FilteredData part of TheData as well. Everything is then contained within your object (see #3 of your assignment). You could make the classes friends, otherwise you will need accessor ("get") methods to access the private data in your filter object (I am not sure if your professor means make both the methods and members private, or just the members).

There's no need to be sorry, but the burden of coming up with examples from your text that exemplify some of these principles is on your shoulders. I've explained that if your class already has the information as private members, there's no need to pass those in as parameters to your methods.

An artificial example:

#include <iostream>
class Example
{
   private:
      int a;
   public:
      Example(int myA) {a = myA;}
      void Cubed() {std::cout<<a*a*a<<std::endl;}

};  

int main()
{
	Example ex(3);
	ex.Cubed();
}

If cubed were private and I had a friend class, I would still be able to access that method, but only from within the friend class. Note that there's no need to pass .Cubed() a parameter, the class already has the information.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Explain to me on line 23 why you are passing in an object of TheData into that method.
When you instantiate a TheData object in main() (which is what I was showing in my last post), it already knows about the data it contains. You don't need to pass anything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't think you can read int from the file using ifstream.

Did you try it? You certainly can.

Glad you got the answer :D

I would suggest you use the following whenever you use a file for data. It may help with an immediate solution that would otherwise be directly hidden from you.

ifstream fin;
	fin.open ("1.txt");
	if(fin.fail() ){
		cout << "Input file failed to open.\n";
		exit(1);
	}

You will be notified if the file is truly there, or not. Should help resolve any potential problems from reading in values to an array from a nonexistent file, or a file not found.

That's not the right application of fail(). Fail() is for detecting when the stream goes bad due to a bad input. Use fin.is_open() instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Above line 6 in the OOP listing, you need to forward declare class TheFilter; so that the compiler knows that the class declaration is available later on.

You still need to rethink your design. Methods in theData shouldn't take a "TheData" object, as they already have access to it. I'd put your filter results as an additional private member of your TheData object. Have your TheData object take the filter as a parameter to the constructor.

This is not working code, but to give you an idea.

TheFilter myfilter;

TheData * timedata = new TheData(myfilter);

timedata.EnterData();  //this method takes in the data, so now timedata has it
timedata.ApplyFilter();
timedata.DisplayResults();

or if you prefer, have ApplyFilter() take the filter object. It's not necessary to pass the data into ApplyFilter as the timedata object already has it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, take the calls to main out from the end of your functions anyway, because it can lead to undefined behavior.

Do you mean how can you combine it into 1 array? Just change line 21 to go from 10 to 20 instead. Also note that in 27 that if your array is N numbers long that the last index is N-1

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're not following your assignment now, so what's the point. Your function definitions should exactly match what your professor gave you. This other code has all kinds of faux pas like calling main() from your functions instead of returning normally.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The actual averaging should take place in "Avgs" with Display functions simply taking those values and outputting them.

Look at lines 31-40. How are you separating the negative from the positive values? You don't need to write the averages back to the index variables (AveP and AveN), as those should be reserved for your final calculation. Instead, step over the array, add positive numbers to a variable called sumpos or something, and keep a count. Within the same loop, add negative numbers to a variable called negpos and keep a count.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Certainly. What progress have you made with the code yourself?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's C++/CLI see http://www.functionx.com/vccli/index.htm for a good tutorial about it. Learn to use the UI designer and determine how to use it to place the event handlers into your code (for example double clicking on button3 will place a button3_click method into your code, just a skeleton, though). Use VC++ 2008 if you can because it has much better Intellisense for C++/CLI (the one in 2010 is virtually nonexistent for this dialect).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please repost the code you are currently compiling.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which reference is it? The hangup here is that you're doing WinForms, which uses a different dialect of C++/CLI. From what I've heard, the best book for learning that is Ivar Horton's (which covers standard C++, C++/CLI WinForms, and MFC). If your reference is teaching Win32, you'll need to change your project type.

Once you decide which of those directions you want to go, someone can point you in the direction of more specific tutorials.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're welcome, thanks for being willing to take a look at that stuff. Without the fundamentals you'll be lost in whatever you have to code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Handles panel1::MouseDown XP = MousePosition.X - this->Location.X YP == MousePosition.Y - this->Location.Y;

What are you trying to do with this line? It doesn't make much sense to me.

Button3_Click(ByVal sender As System::Object, ByVal e As System::EventArgs);

This looks a lot like VB.NET to me. The languages can interop on an assembly level, but you can't just intersperse the source like this.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Before I look at this at all, you need some formatting lessons. Please, please take a look at http://www.gidnetwork.com/b-38.html. At least you got it into code tags, but no one can read what you have above, with everything jammed onto one line. Please repost it with proper formatting.

main should return an int, but yours doesn't even exist, you just end it with a semicolon. Pick a thread that has a main and functions and note what the layout looks like.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

My first problem is what is a switch statement and what does it do in this program?

Why is there a break after each case (I know it changes the flow of control of the program but I am not clear how it changes it).

What does cout << ..; mean?

You don't sound like an annoying mooch, but you can google just as well as we can. However, even just googling "cout" brings up 3-4 good links (google ignores punctuation, etc. so the "<<" part has no effect). Certainly googling "C++ tutorial" should get you a few pages worth of introductory material. The other thing is, since this is your science project (and even if it weren't) experiment with different lines of code to see how they behave.

lastly, get yourself a book on c++ and write simple programs before moving onto big things.

is spot on. Simple programs means really simple. Print something to the screen in one, add 2 numbers in another then print them to the screen, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The OP is correct, he/she wants to make sure that if either of the times doesn't have a colon, the time is bad.

!(A && B) is equivalent to !A || !B by DeMorgan's law(theorem, whatever)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Head First C# is a great introductory text that is very "active" and engaging (for people of any age group). There's a new edition for C# 4.0. There's not a lot of depth to it, but it covers a large chunk of the language and has some fun labs.

kvprajapati commented: very good book indeed! +11
NorseOg commented: stupdity +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure. Do you have the full VS? If so, there may be a problem with your Platform SDK installation.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can certainly post whatever you like. I was just stating that a ton of code is less likely to be read by most people. This is an ideal chance for you to learn to use a debugger (or the poor man's debugger using cout statements) and figure out where things are going wrong. Start small, make a fresh file and cut and paste small portions of it in, compile it, test it, if it works, paste more in there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you have an Express Edition of Visual C++? If so, you are probably trying to compile an MFC program with it, and you need the full version of Visual Studio for that.

EDIT: Edged out by AD by a hair

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't want to speak for anyone else, but rather than having someone do an entire walkthrough of your code, you could pick out sections that are problematic, and post those. Someone is much more inclined to wade through 20-50 lines rather than a few hundred.

If you have large scale problems like "why the heck can't I get input from a file on days ending in 'y'?" then google around for some solid tutorials and take yourself through them (since you'll have less code to write from scratch) and try to learn those techniques through 1-2 of the assignments rather than posting every single one that requires that technique.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What type of videos (mp4, flv, etc) are they? You're probably going to need to use a Windows Media Player control http://msdn.microsoft.com/en-us/library/dd564582(VS.85).aspx or another API appropriate for your video type.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is MainProgram.h? Do this: pair one function with a main program. Get it to compile. Add the second function, get it to compile. Look in your text or on this site to see examples of programs with multiple functions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have been in graduate school in the mighty neurosciences in the past, and I'll tell you that it's nice to be able to program, but Matlab should probably be your main focus. There are options to compile it (into mex files) and to generate C code from it. There are plenty of solutions for MRI that are already in packages (SPM in Matlab, Brain Voyager for standalone). Many have scripting capabilities.

Before I take this too far OT...

It can't hurt to learn C++, so a good book is probably Koenig and Moo, "Accelerated C++." It teaches C++ for C++'s sake (and not "built upon" C). I like C++ Primer Plus, but that takes the approach of building off of C, so it starts off with a lot of procedural programming.

Anyway, send me a PM if you want to know more, as I'm sure the faithful readers don't want to hear me tell old "war stories."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why does your function on 324 return float? You are using doubles in the body of the function and then trying to cram the double (with it's additional precision back into the float). This is a warning from the compiler but it should be addressed.

Change line 30 to srand((unsigned)time(0)); to ensure that the value returned from time() is explicitly cast into an unsigned int instead of a variable of type time_t.

Your problem is that you have no main() in your code. The compiler needs to have an entry point for your program.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There can only be one main per project, as the compiler has to know where the entry point is. It can be in the same source file as your other code, or by itself.

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

Please use the code tags.

You can do everything within one loop, and you don't need any of the character arrays.

Are you limited to capital letters?

In pseudocode:

1. Read in a line using getline (with the std::string overload) increment the line count
2. Make an [B]int[/B] array that's 26 elements long
3. Crawl that line, checking to see if each character is greater than 'A' and less than 'Z' (or use isupper() in <cctype> if you are permitted).  Count each letter using your int array.  Use the count of characters that the std::string has in length()
4. Perform all the calculations necessary
5. Repeat ad nauseum

A minor point, but use if(!infile.is_open()) instead of fail() . Fail is to check if the stream goes bad.

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

I see what you are saying. However, I believe you'd have to "count()" over the line 26 times to get an array of letter counts. We don't even know if the OP can use the STL for this assignment. I agree with your getline approach, but when it comes to the individual lines the approach that WaltP and vijayan are advocating would probably serve the OP better.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think I haven't stepped through each character at all.

You would have to in order to get the frequency information.

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

If you're talking about making a Windows Forms application, see http://www.functionx.com/vccli/index.htm for an intro to the malevolent world of C++/CLI. If you are after MFC (only available in the full version of VS) google for tutorials on that. If you want to do things at a more fundamental level (Win32 API) then try www.winprog.org/tutorial/ Note that there are also other options for windowing with C++ such as Qt or wxWidgets.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't have any examples in C++/CLI. There are quite a few example sites for C# that will give you the namespaces and the methods (and you can convert them to C++/CLI directly). See http://www.c-sharpcorner.com/uploadfile/mahesh/readwritexmltutmellli2111282005041517am/readwritexmltutmellli21.aspx.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You do not need the datatypes when you make the calls in main() on lines 68 and 69, that is what the compiler is choking on. However, there is no need to pass the object into itself, as it already has access to the members and methods.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

loop from 0 to listBox1->Items->Count and writeline listBox1->Items->ToString()

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's NO NEED TO TYPE IN CAPS. We can hear you just fine. If you are working in C, this should probably be moved over there. I'll flag it for a mod.

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

Would it help you to know that subtracting '0' from '1' though '9' gives you the integer value of that character?

'1' - '0' = 1
'2' - '0' = 2
etc.

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

I hadn't actually tried to compile it, but it does use some preprocessor directives to change the InfernoDevelopment() into main(). So, there is still a main() once the program compiles, it's just obfuscated in the source, so bravo to pradeep. However, this could have been 100x better if he/she offered some explanation and wasn't shamelessly self promoting.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use code tags

It was spam anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not a board-certified psychiatrist, but I'm fairly sure that's not the case. I think he suffers from CDH, can't do homework.

Just as a PSA: The more your title cries out for attention, the less attention it will get. The more intelligently written your title is, the more help you will probably get.

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?