jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What you are probably going to have to do is read your text file into the workspace using fscanf or using the import command on the file menu (versus importing them into the NN GUI) and manufacture the matrices at the prompt.
From your example:

Cutting speed: [600.04 600.04 600.04 750.06 750.06]
Feed rate: [229.2 229.2 229.2 286.5 286.5]
Depth of cut: [3 6 10 3 6]

Take in cutting speed values into vector cs, take in feed rate to vector fr, take in depth of cut to dc. trainingmat = [cs;fr;dc]; (my syntax may be off but you get the idea)
Then, import trainingmat from the workspace into the NN GUI. Make sure you have the input units set to 3. Do the same thing with the
output data.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does the code look like now and what does your input file look like?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use your getline statement to drive a while loop (I'm assuming you don't want the blanks you were just finding a way around them)

while(std::getline(cin,command,'\n'))
{
  //Other statements here
}

When there's no more input the loop should exit. Make sure that in your file you don't have extra blank lines at the end.

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

By the way, what dialect of C++ is this again? Never seen it before.

Nevermind I looked it up. Scary, moreso even than C++/CLI.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

everything else seems to do its job as planned

Well, something is happening somewhere that's what makes it difficult to discern. Fleshing out the code a little bit to get something that compiles I was able to print out what had been push_back'ed. You have "Person" on line 22 instead of "person" but I suspect it's more from your paraphrasing than an error in the code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If the code's not too unwieldy please post the whole thing so I can test it out.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's a "hard space" that you probably copied in from a web page by mistake. Either find the line that it is on and put the cursor on the beginning of each space, hit delete to clear it then hit spacebar (do that for each one) -or- copy the program into Notepad, save it as ASCII and reload it into your IDE.

By the way, what dialect of C++ is this again? Never seen it before.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where is storeinfo defined? (in other words what is it a method of)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
int index = op.find_last_of('.'); //search from the back of the string
op = op.substr(0,index);  //take the first #index characters (doesn't include period)
                    //could do substr(0,index+1) to keep period and append
                     //"png" instead of ".png"
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use a combination of find_last_of(to get the last period) and substr(to grab everything up until that point) and then append the .png to the substring.
Or if you know your filenames are always going to be a fixed length, just overwrite the last 3 letters with "png" (op[15] = 'p' etc).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

the [] only work if string is defined

Yep, just came to the same conclusion.

I think what you meant Tetron was to substitute output +=alpha[r] for the output[r] = alpha[t] .

Another option would be to dynamically allocate a char array but that wouldn't be able to take into account repeats in the letters of key.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

no i diddnt put getch(). What does that do?

Unfortunately getch is part of a nonstandard library for console input. A portable solution would be to put cin.get() in the same spot.

iam using visual c++ 6.0 on windows 7 64bit. so could it be compatability issues thats causing it to crash?

This is not outside the realm of possibilities. Try downloading the 2008 express edition as VC6 is almost 12 years old.

thanks for the reply jonsca but i forgot to mention that i need to do other things with the array afterwards. i was just outputting it in this instance for testing purposes

Gotcha. I'll try running your code and see what the outcome is.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There doesn't seem to be any requirement to keep an output array, so it may not be necessary to shift the arrays all around if you are just outputting the results to screen. Just say if alpha !='0' then output the character.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're still missing out on how the objects should be used. Your object contains a numerator and denominator and a way to print itself. Therefore you should have

Rational myrationalnumber;
myrationalnumber.setNumerator(2);
myrationalnumber.setDenominator(5);
myrationalnumber.showfraction();

which would print out 2/5
Then you can make another object for the second rational number.

Your class defines what the object has for members and how it behaves. Each object carries around its own numerator and its denominator. It knows how to print itself, therefore you don't need to pass it anything to print as it has access to its own member variables.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I believe the objective of the assignment is to have one instance of the rational class which contains both the numerator and denominator for the first number and another instance that contains both numerator and denominator for the second number.

As other posters have pointed out, your setter functions are potentially incorrect also. It is customary to have:

void Rational::setNumerator(int numerator)
{ //set the private variable by the value being passed in
     Numerator1 = numerator; //following the name of the private 
                                         //variable from your class
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The OP wants to print the letters not used in the original "key" after they have output said key (I think the OP left an h in the extra letters of the example which was confusing).

I would use a string like lotrsimp said, but in your alpha collection write a number or other character over the used letters so if your key were "abd" your alpha string would look like "00c0efghijklmnopqrstuvwxyz"
A simple if statement gets you the chars you want.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where do the hours data for the first person go once you read in those of the second person? I would make that a 2D array also.

If you're going to read in a name with a space in it you won't be able to use cin. Use cin.getline() instead.

Use an while loop (or a for loop) around everything to step through the names and within that while loop use the one you have there to input the hours data.

int j = 0;
while(j<3)
{
      Enter the name, etc.
      while(i<6) //only 6 days worth, start i at 0
      {
              input hours
              if statements in here to check for overtime and too many OTs
      }
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No need to apologize. Yeah, you don't want managed. Just to be safe, create a new project. In the dialog box that comes up go to Win32 Console application (not Win32). Deselect precompiled headers. Add your code back into the project by right clicking on the project name and using the Add..Existing Item... option in the Solution Explorer (or you might be better off creating a new (unmanaged) class--also under the Add...menu--and copying and pasting your information into it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you trying to compile it as a CLR application? (I noticed you added in the ref class keyword). If not, change your project type to Win32 console app, that will get you the standard C++ flavor.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

when they're not home, because I'd get in trouble

Yet another latchkey kid gone terribly wrong. At least you've learned to write quality code in the process. To "bolster" my claim of you being older I wanted to find the poster who accused you of being middle-aged and bitter but I can't locate the post. Argh.

Dani is Al Gore

As long as "she" (Al) doesn't (mis)use the term "Information Superhighway" everything will be ok. She seems to have more personality in the tip of her pinkie than he does in toto. Well played in throwing us off the track, Al.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What makes you think Narue is female? (s)he admits (s)he is a witch, so (s)he could be either or both.

But her profile says "Code Goddess"! And Dani is the most powerful on Daniweb . . the God of Daniweb. I'm convinced.

Don't make me rethink my entire worldview. ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What have you tried so far?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What have you tried so far? It's a matter of parsing the hex digits 2 at a time and converting them to decimal (for digits, convert to an int by subtracting '0' and by using a switch statement to convert a or A to 10, etc.).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Being from the same "generation" of members I've noticed this too. There are others in the same boat.

Give this a read: http://www.daniweb.com/forums/thread229580.html

Since this has been an issue of great debate I'm persuaded to think that it makes sense this way over the long haul.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Give this a read about the parentheses operator. It's partly relevant to your problem. When you are thinking about how to divide the numbers up, if row and column are the position of any one element, what is the relationship between row and column in any of the 3 matrices?

Have a go at it and then we can help you with whatever code you come up with.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What would the value of strlen() return in that case?

Argh... Yup, brain fart.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That seems reasonable, but what if the buffer is 20 characters and the user only enters 4 and hits enter?

WaltP commented: Are you being silly, or are you having a brain fart? ;o) +11
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

(I don't remember if C uses .size or .length for arrays..).

Neither lol.

int i;
for (i = 0;array[i] !='\0';i++)
{ 
    if(array[i] =='\n')
       array[i] = '\0';
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you mean to post this in CompSci?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A departure from the topic a bit, and this article I found is getting to be a bit dated, but have you considered some kind of "macro recorder"?

Yes it can.

WaltP in 2012?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

IMO, you could have a system where posts on threads over 3 months old require moderator permission. It's more work in the short term but having to take the time to approve 5 threads rather than having to close 20 for the usual spam,"I have a totally unrelated problem but this thread looked good or had a lot of posts on it" etc. it would end up saving time. Sure it takes a little bit of control out of the hands of the community but if that's the chief complaint then why have moderators in the first place?

jephthah commented: word +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
declares an array of strings    
    string item_name[number_of_items];
    
    cout << "How many items does the customer have? \n";
    cin >> number_of_items;

When specifying the size of an array in the declaration like that on line 22, the value of number_of_items must be known at compile time (unless you have certain language extensions on when you are compiling, but that runs the risk of your code being non-standard).
You have double trouble because even if it were legal, you declare the array to be that size before the user gets to input a value.

Your best bet is to prompt the user for input but then create the array dynamically. So scratch line 22 and around 26 put in a: string * item_name = new string[current_input_number]; Check your for loops also: remember that arrays are 0 based.

EDIT: Sorry I stole the thunder of your teaching moment WaltP

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put in a cin.get(); in between lines 9 and 10. It's along the same lines but it's also nice and standard.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I do not understand your code... First you should have just used

using namespace std;

instead of waht you did, you also did not initialize your variables,and then you kept repeating the same conditions:

using std::cout;
using std::cin;
using std::endl;

is actually perfectly acceptable and in many situations preferred to bringing all of the std:: methods into the current namespace. The way it was written the only methods that can be called unqualified are those 3.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was willing to help you. I'm not going to simply give you the answer because you'll have to keep coming back and having me iterate through your compiler errors every time something comes up. I was just saying look over some example programs in your text (or a text) because you're missing some fundamental points.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, but I'm not going to be a compiler interpreter for you. Read the other things I told you. You need to have 2 integer values to return GetNumber1() and GetNumber2() into. So declare 2 ints. You'll need another one for CalculateResults. I don't see your PrintResult function anywhere so you need to implement it. You have it returning a value but you may not need one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You use it in a similar way to gets except you specify the maximum size of the char array you are reading into.
Take line 33:

fgets(Stud[i].Name,sizeof(Stud[i].Name),stdin);
(or you could put in 20 for the sizeof(Stud[i].Name) portion)
(last parameter is there in case you wanted to get input from a file, so you just need stdin to get it from the input stream)

Just be aware that fgets will take in a '\n' character into the string/char arr when you press enter, so you may have to step through your char arrays and substitute a '\0' for the '\n' (fgets will append a '\0' to the end of the input anyway but this way you terminate it at the proper point).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Lines 22 and 23 are prototypes which should in 99.9% of cases be placed outside of main replacing lines 11 and 12. GetNumber1() and GetNumber2() functions are returning values and you're not "catching" them with anything like a variable local to main().I understand what you were assuming but the x and y within those functions is out of scope so they can't be seen in main().

Look up some examples in your text as to how functions are called in main(). They don't need the return type and you don't need the type on the parameters either.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Once you've got the control on the form in your code add an event handler to it programatically.
For example: this.panel1.Click += new System.EventHandler(this.panel1_Click); (and of course you need to code the panel1_Click method just like you would have done by clicking on the properties window).

Then just use the panel1.Name or panel1.Tag members to set a name to use in your program and display that in a messagebox or whatever you had planned to do.)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your work sounds really interesting. Unfortunately, I don't have any concrete input for you. I'm familiar with some time-frequency stuff but applying that would be a guess on my part. However a good place to direct your search(in addition to posting here of course) would be in IEEE Xplore database (http://ieeexplore.ieee.org/search/freesearchresult.jsp?newsearch=true&queryText=speech+recognition&x=0&y=0). Even reading the first set of results there seems to be quite a few methodologies used. You need a subscription to access the full text (I don't have one any longer) but you could probably go through the abstracts and google off of the terms that sound promising or see if the investigators have copies on their website.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please use code tags in your next post. They are easy to use and help everyone read your code (and therefore help you) more effectively
Simple as:

[code]

//code goes here //more code

[/code]

main() returns an int (always).

Don't use .eof when reading in files(see this). So use your myfile1.getline to drive the while loop.

You don't need to use delete for buffer unless you use new.

In terms of your actual question, you can send a newline to your output stream just like you would send it to a cout, using endl or '\n'

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Think of P0 as a point on your shoulder, L0 to be the length of your upper arm, and L1 to be the length of your forearm. Now, put your finger at an imaginary point in space (don't allow your wrist to rotate). That's P1. Now if you have P1 and P0 you can use something like http://en.wikipedia.org/wiki/Law_of_cosines you can get everything as a function of the angles (since you know the distance from P0 to P1 too and you can assume your upper arm can rotate at the shoulder). I don't think your professor is looking for an exact answer but something in terms of the unknown quantities.

Anyway, hope that gives you some hint without ruining all of your fun.

Salem commented: Very nice analogy! +19
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint, how many stars are in each row.
Row 1 ___
Row 2 ___
See any pattern you can use?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So print out avgRain[x] between lines 21 and 22 (as WaltP was suggesting) check to make sure you're getting something there. You also don't check the status of the file with the is_open() method. It may be that you're trying to open something in a directory outside of the one where the program is executing. Do some tests. Make your data file simple initially, one line or one or two numbers and then substitute in your real one once it's working.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you using Windows or *nix? windows.h has a sleep() function.

See this thread about ways to do it with the ctime header:http://www.daniweb.com/forums/thread233015.html


I know you're not asking for help on this part, but you should reform your goto into a do/while loop. It's a lot easier to follow that way.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're not the only one (by a long shot) that has that situation. I know you can't do anything about it, I was just giving you a hard time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you check line 13 like the compiler was telling you to? You only need a semicolon after a prototype but not in the function definition.

What I was also saying before is do you want to increment a and b within your function? Remember this will change the values outside as well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I should use it like this cuz we kinda study it like this and I don't wanna mix things up

Okay, but just be aware that for all the rest of the programming world, we like to leave 1993 right where it is.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You missed the obvious option, jwenting. Open the skull, put black ink over the cortex, stamp it on a sheet of paper. Voila, brain fingerprinting.