jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Read in the lines using a while loop and getline and compare them with "label1." Once you find it, read those next 5 values in using a for loop. Once you've done that, break out of the loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, if you have spaces you'll need to use getline.

std::string input;
getline(cin,input); 
//or if your string is guaranteed not to have spaces, cin >> input; will work
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Add the functionality in the order that it's listed in the instructions.

Make the function. Test the function in main a number or two that you know.

Test the function on one number. Figure out how many factors it has.

Repeat for all of the other numbers.

Diagram out your plan of attack on paper first...then post what code you have so far, and someone can help you from there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

a value digited in a dialogbox is put into my original variable from the code.

Well, if it was a textbox (and I don't know anything about wxWidgets, so I'll speak in generalities) it's likely a string of some sort. If the user types a number in that box, you'll have to access the string, turn it into a number, and then add it into your vector.

//inventing my own GUI toolkit with a JSTextBox object
std::vector<float> fv;
std::string textboxval = JSTextBox1->Text;
std::stringstream ss(textboxval);  //other ways to do this
float tempvalue;
ss >> tempvalue;
fv.push_back(tempvalue); //so instead of adding to your vector directly in the code, you have to parse the value from the textbox

run the program in "background"

You'll place the code for that stage of processing in a button handler, so that when you click the button, that code is executed.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Unfortunately, it's a pain (but not impossible by any stretch) to retrofit a complete piece of code to a GUI.

How comfortable are you with the GUI toolkit already? (like have you made a "Hello, GUI" with buttons or are you able to display a text file in a textbox? Those are the kinds of fundamentals that you'll need to get up to speed on first before trying to figure out where to place your existing code. With those ideas in place, you should start to see how things can be parceled up.

Since most GUI libraries are OOP based, in my opinion it is slightly easier to use objects with them. IIRC, your code that you were writing was more procedural, so I don't know how viable an option it is to do that.

Try it out, and see what specific problems you run into.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Make sure AcceptsEnter is false for the textbox(it is by default). Make a keyDown event for the textbox. Within that event handler have something like

if(e->KeyCode == Keys::Enter)
    button1->PerformClick();

or whatever action you need to take.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you want to capture it in place of a button press (like you would in an instant messenger) or...? What were the instructions in C#, perhaps there's a property of the form that's called something different. There's a property where the keypresses from the textbox are also passed down to the form, but I forgot what that one is called.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to add the \bin directory of the mingw folder to your path. Ex: http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx for Windows 7.

Another thing you can do is make a shortcut to a cmd window that runs a batch file that sets the path for that window only:
(call it mingw.bat or something)

@echo off

set PATH=%PATH%;C:\yourmingwpathhere\bin
set PATH=%PATH%;%SystemRoot%\System32

Then, create a shortcut (right click on the desktop, new, shortcut) and put %COMSPEC% /k c:\yourbatchfilepath\mingw.bat (change the Start in: directory to wherever your code is, so it goes to that directory each time).

Then, once you have your file above saved as native.cpp (or something) invoke the compiler by typing g++ native.cpp -o yourexecname

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which compiler do you have installed?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
char inputFile;

Or I guess you could change inputFile to

char *inputFile;

That will most likely cause a crash when you try to write to an uninitialized pointer like that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think it's fine to do as a subclass, but that's just my opinion. If you are treating EmployeeData objects as "nodes" on an EmployeeDataList then that is a common style.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And EmployeeData is meant to be a subclass of EmpDataList.

My bad for assuming. SkyDiploma's solution should work then. If you want to keep things a bit more organized, put your declarations for EmployeeData wirhin the other class.

class EmployeeDataList
{
    private:
    class EmployeeData
    {
         private:
         
         public:

    };

};

That way you don't have to play around with the extra header file and the compiler is happy.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take in the input as a std::string and use the .c_str() method of the string object to get the const char * representation.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Great catch. I suspect all that the OP really needed to do was to put "friend" in front of line 4 of your top listing. I don't know if the OP wanted to make it a subclass or not.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
#include <stdio.h>

void function1(int a,char c)
{
   printf("This functions parameters were an int %d and a character %c\n",a,c);

}

int main(void)
{
   int x = 2;
   char b = 'q';

   function1(x,b);

   return 0;

}

Can you be more specific about what you want to know

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Post all of your files in a zip and I'll try to compile them.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's important for us to see what you've tried before offering you our assistance.

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

You're not calling your functions anywhere within main(). It's simply outputting your input all in a row, as that's all you've asked it to do.

You need to name your functions better. Ave is finding a sum, and out is finding the average. That's confusing to anyone trying to read your code (especially your professor).

Your other functions operate on doubles. Since S1,S2,S3 are being passed in as integers in the "out" function, if you pass in a double value, it's going to be truncated down to an integer, so 16.4 would become 16, etc. To make matters worse, on line 42, you're summing 3 integers and dividing by an integer, which no matter what type "Grade" is, you'll get an integer response. So for S1+S2+S3 < 300, you'll get zero for a grade.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Again, your data are ideal for using ">>" (with getline you have to do all of the parsing to get the numbers back)

string throwaway;
vector<vector<double> > data
while(is >> throwaway)
{
      for (over the vector indexes)
      {
         Read into a double using >>, push_back onto 1D vector (one for first row of the 2D vector, one for the second)
      }
      Push 2 1D vectors into 2D vector "data"
}

(easier if you represent your 2D vector by a 1D vector with 4 elements)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Read the entries in using the extraction operator >> (so you don't have to convert from text to numbers, just read right into doubles)

I read the text file, but are you saying that there is:

Text  1.0 2.0 3.0 4.0
Text2 etc.

because you can extract the text first and then throw it away.

In terms of the variable rows, you can simply use the .push_back() method of the vector and you won't have to keep track.

fgets is a great function, but it works with C-style FILE* pointers instead of ifstrea

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Show the line(s) that you are using to put it into the text file. You may be adding endl to the end of the line when you don't want to. If you're then, reading it back into a string, something like getline reads to the end of the line and discards the newline character.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 56, rename posi to posi_short or something, as it's overwriting the value of posi that you found for the longest word in the previous for loop.

I was just saying that you don't need a second for loop to test for the shortest value:

for( )
{
   if(count is longer than longest)
   {
        longest = count;
        posi = i;
   }

   if(count is less than shortest)
   { 
        shortest = count;
        posi_short = i;
   }

}

Save yourself from making two passes over the data.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Think about it, you can find the shortest and the longest all in one pass. Name your variable that marks the position of the shortest word as something different so it doesn't overwrite the one for the longest word.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

By doing something similar to what you did for the longest word?

if(count < shortest_word)
{    
    shortest_word = count;
    short_posi  = i;
}

Start longest and shortest initially as the length of the first word. If you have shortest_count = 1 then it's going to be tough to find something shorter than that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, you'll need a while loop and the >> operator.

std::string tempstring;
while(ifs >> tempstring)
   Add tempstring to vector

Play around with that with different text in your file, like

"Does it tellthewords apart what happens      if there's a big space, or punctuation!"
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Based on what arkoenig has told you, you could read in the words one by one into a vector, as the extraction operator(>>) is delimited on space (probably would have to get rid of punctuation first). That way you wouldn't have to keep track of spaces at all. You'd just end up with a vector full of words and you could perform whatever manipulations you needed to process them.

Not sure what'd you'd need a struct for in that mix.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Actually, I see what you were trying to do with the "next", so maybe that was in the right place in the EmployeeData. You just needed to qualify it as EmployeeData::next so that the compiler knows where to find it (since the two classes are friends).

As to the other problem, you included employeedata.h in employeedatalist.h, and then included employeedatalist.h in the first code box listing, so I'm not entirely sure what it's complaining about. Did you change the code from the first time you posted it, as there is no EmployeeData object on line 12 of the file?

Also, don't do #include "employeedatalist.cpp" . Compile the two files together or make them part of the same project in your IDE.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to designate that getData is a method of EmployeeDataList, since it's not defined within the class declaration.

void [B]EmployeeDataList::[/B]getData(fstream& dataFile)

Then you still need to declare "next" as a member variable of EmployeeDataList to avoid the second error.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, so you've started to plan out what you need, that's a good thing. Start trying to code it.
-Can you make the numbers increase over each row.
-Do the counts of the elements in the rows bear any relation to other variables?

Plan out what you want with pencil and paper and then try to translate it into code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've used vectors in your other threads. Think about things you could do towards this problem with a vector of strings (or even an array of strings, if you wanted to practice those).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, so trace through that sample file with a pencil and paper. Where are the capital letters necessary? What separates the sentences from each other?

Once I hit the period, there is a ________ or a _________. After that, if there is a letter, capitalize it.

Now translate that into code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The specification says that the sentences are separated by periods. I'm assuming there won't be a space after the period. Keep track of the last character you read, if it's a period, capitalize the next letter. If there is a space, you'll need to skip over it before capitalizing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's telling you exactly what the problem is. Look in Form1.h for a missing right brace instead of this file.

Think of it this way, when you #include a header file like that, the text is basically pasted in at that point. The compiler found the opening brace in Form1.h, but it has reached all the way to the bottom of iLab6B.cpp and hasn't found the matching closing one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
aInt = atoi(ch[0]);
bInt = atoi(ch[1]);

Except that there's a space at position 1.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The header file is fine. You could implement the method (function) definitions in the same file as main if you wanted to

#include "mortgage.h"

Mortgage::Mortgage(//params)
{

}

Mortgage::calcpayment(//params)
{

}

//more definitions

int main()
{


}

but people usually place the definitions for the class in one .cpp file and the main program in another.

It won't take you long, you just need to copy/paste some stuff around and make sure that your definitions match the declarations in the header.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why are you redefining the methods with different parameters on lines 13 and 14 of your prior listing? You need to define them with the proper parameters on lines 18 and 19 of the new listing. Then, you need to define the methods

Mortgage::Mortgage(double Loan,double rate,int term)
{
   constructor code here
}

double Mortgage::calc_payment(double yada1,double yada2,int yada3) 
{

}

It's probably a good idea to take a spin back through your text or your favorite online resource to refresh some of these concepts before trying to write the code. I know it seems like it will take more time, but if you have the concept down it will in fact go much more quickly.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's my understanding that it's a perfectly viable option to use a native C++ DLL with an interface designed in C#. I'd say go for it. It's not a problem that you're noobish.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's looking for the definition of the constructor for the Mortgage class. Is that in this file or in another one? If it's in another file, you need to be compiling the cpp files together (or make them part of the same project in your IDE).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So that event handler isn't firing at all. Go through the code and check all of the event handler hookups this->systemBOX->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged); as this particular one is hooked up wrong.

What is comboBox1? You want systemBOX's SelectedIndexChanged event to be associated with systemBOX_SelectedIndexChanged (the event handler you have in your last post) not comboBox1_SelectedIndexChanged.

I'm happy to help you, but you've got to keep track of your own code, and if you don't understand the mechanics of these things you'll have to do some reading on them, or at least rely on the IDE to put them in the right spot for you.

You were asking about sites before, the functionx.com site is decent, but it's definitely the most comprehensive out there (http://www.functionx.com/vccli/index.htm)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Both numbers are on the same line, so you only need one fgets call, I think. Then you can get the digits from the string or use sscanf (but that's probably overkill).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You shouldn't have semicolons after your function definitions on 102,107,and 131.

process() should have a closing brace somewhere.

Line 97 will declare a Mortgage object that will be destroyed after process() completes (once you put a closing brace at the end of the function).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Within that same event handler, put in

MessageBox::Show(systemBOX->SelectedItem->ToString());

and see if the messagebox pops up with the string, to make sure the event is firing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

toString

It's ToString() (case counts). The intellisense in 2008 is nice, as you can just type your object's name and then the -> and it drops down a little menu to select from. There's some in 2010, but I don't think it works for everything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

http://www.mingw.org/wiki/InstallationHOWTOforMinGW

Grab the latest mingw with that installer and then get the Code::Blocks IDE that doesn't include the compiler (or see if you can configure your IDE to find the new compiler).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is your ComboBox called? If that's not the right name, change it to whatever it is named on your form. In fact, probably should erase that event handler code and let the IDE regenerate it for you. Double click on the combobox on the form and the proper handler will be placed in the code automatically. Then, use the SelectedItem of that combobox and it's ToString() method.

Just a suggestion, but if you don't need .NET 4.0 stuff, you can get away with using VC++ 2008 Express Edition, which has much better intellisense for C++/CLI than 2010 does (shows you their priorities).

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

Use gcc for the compiler, use whatever editor (Emacs or vim) for the editor. Anjuta looks good but it's unnecessary.

http://www.dosbox.com/download.php?main=1
The designers seem to think it's cross-platform.
Look before you leap.

Windows	 0.74	 Win32 installer
[B]FreeBSD package	 0.74	 TBZ
Fedora	 0.74	 rpm
Gentoo Linux	 0.74	 portage
Source	 0.74	 Source [/B]
Mac OS X	 0.74	 dmg (Universal)
RISC OS	 0.74	 zip
Solaris 10 - sparc	 0.73	 pkg
OS/2	 0.72	 exe (OS2)
BeOS	 0.63	 binary (x86)
Old dosbox versions	 0.50-0.73	 source + binary(x86)
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm always a bit confused by the interaction of the managed and unmnanaged code. I think pointers are still one of those dicey areas at that interface. When you're compiling under /clr:pure, it's mandatory to use the "marshalas" functions to shuttle data from one side to the other. When you relax the /clr level, I thought that the two sets of code were more cooperative, but that may not be the case. This is something I'd have to look up.