jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, I have noticed this on my profile page too and have reported it to Dani. So, you're not alone :)

I'll let her speak to any findings, though.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You are using two headers which prevents me from compiling this code, as I don't have them

You can get the second one from BS's page (it's just a mishmash of #includes, template functions,etc)http://www.stroustrup.com/Programming/std_lib_facilities.h

stdafx is needed for precompiled headers. If the OP doesn't have anything listed in there, you can skip it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For that code (at programmer's heaven) you'll have to include conio.h (if your compiler includes it, many will not,which comes with all the caveats of being non-standard) and include ctime to get the time function.

In that code they are taking a whole character array in, so you don't need most of it.

Try out the _kbhit in a couple of "toy" programs first, then add in the timing. See what you can come up with and post your code for this section and we can take a look.

...and no need to be sorry. This is just one of those areas where there's no clean way to do it is all.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here's a freebie but I am sure that you can find many more via Google

http://www.eformulae.com/

This may be a case of once you've done a few of them the translation will become second nature, so you may not need that many.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the getInFile defined as?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're method is definitely not doing what you think it is. It may be "legal" in that it compiles but the logic is far different.

The variable you read from the user is boolean. It only takes the values true or false. However, it seems that when you enter a number via cin, it is recorded as true (1) if the number is 1 and false (0) for everything else (I would think based on the points below that the value would be 1 for every number except an input of zero but it doesn't seem to be the case). So when you are inputting 2+2 or something, it takes the 2 for the input (since it can convert it to a value) but leaves the rest of it in the input stream (so a subsequent call to cin could pick it up). It was not getting your whole equation.

A word about boolean statements. A value of 0 is considered false and a value of anything else is considered true. So if we have the statement:

if(1)
{
   std::cout<<"Hello."<<std::endl;
}
then Hello would be printed.  

It would not be printed for:
if(0)
{
  std::cout<<"Hello."<<std::endl;
}

So in terms of your statements, look at if(expression == true-true) Say we entered in 2+2, so 2 is read into expression as 0. Since subtraction has a high precedence than ==, true - true is evaluated first (as 1 - 1, even though anything other than zero is considered true, …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What if I were to wear a wig and a dress, would that help? :)

Anybody got a scouring pad I can use on my brain?

Lost you the first time while scanning for good looking chicks who are into programming

It's like Wyclef Jean said: "should I ask her for a dance, hold on, there's too many in the wolf pack"

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Search the forums there's an example of one from about 6 months ago. It was an outdated example so you probably don't want to reference too much from it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 51 -- check your = vs. ==

deleteNode is incorrect as you need to translate your position into i,j
(see your instructor's comment)

// This array will hold the data. Notice we only need a
// one-dimensional array since each node is represented
// in both the rows and columns of the adjacency matrix.
// So we'll use rows, but columns will also work.

I didn't try to run it but take another crack at it with those things and set up a main to test it with. There may be other logical errors but those are the most obvious to me.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Rather than getting it character by character, why don't you read the word into a std::string and capitalize that? Hint: std::strings are arrays and can have their chars changed one by one if necessary.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ah. I commented on the availability of the boost without verifying what the function did. Props to firstPerson and apologies to the OP. I thought maybe the boost class offered a timer_tick() handler like in .NET.

There are at least 3 ways that I found to do it.

This one involves the ancient and nonstandard conio.h functions
http://www.programmersheaven.com/mb/CandCPP/310380/310380/time-out-of-getch--command/

This one offers a link to a win32 program partway down the page and goes into some of the options with pdcurses(http://pdcurses.sourceforge.net/ which is a slightly more modern interpretation of curses/conio)
http://www.gamedev.net/community/forums/topic.asp?topic_id=538714

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ok, thanks for understanding. First off, I'm a bit confused about the void type that's declared for the myswap function. They say void is used for types that do not return values, but doesn't it return a value? I would think that it returns the value of a and b by looking at it. So you can see how much I understand this, not very much. Next, I understand how the swap takes place and a and b are going to swap with x and y. Now if I were to replace (int & y) with (double & y) would that create an error? Because I am trying to pass an int and a double to the function. Or, will the double convert automatically?

In this case there's nothing being returned, that is the function has no value when we've returned to main. Don't necessarily think of the parameters you pass in as being returned, it's almost as if you would be using the variables defined in main right in the swap method itself.

If you were to replace one of the ints with a double it would give you a warning just because of the nature of the function I created (assigning one to the other would truncate the double to it's integer portion when it was assigned it to the int). For what you intend there should be no problem.

By the way, I looked at a swap function using pointers and the difference that I …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If it's a compilable piece I usually try to run it, or if it's a function that I can couple with a small main to test.

Your problem with your current code is on line 52:

while (inStream >> next);

That was the problem with the other one, you had a ; after the while statment causing it to run just the inStream part without having it run the inside of the { } except once after that was complete.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

He had the a^2 there. Doesn't matter, glad you got it working.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Assuming you have some experience with pointers this has a great summary in the top post about references versus pointers. If you don't have any experience with pointers, look up a swap function using them and note how it's different from the one I showed you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry I was just trying to get a better understanding of the concepts of functions and references. After reading your response to the previous thread I was confused and wasn't sure what you were trying to tell me. I think my problem lies with not understanding functions and multi values period let alone using references. I was wanting someone to give me sort of a tutorial on this before I went back to tackling the problem again. I sure do thank you and everyone else who has helped.

It's okay, just didn't want to you to think that you couldn't ask for clarification. I'm not sure what you mean by multi values. Functions can take any number of arguments (parameters). There is definitely a finite number that you can have but it depends on how large the stack is, so don't worry about that for now.

Functions are analogs to their counterparts in math. y = f(x) takes one value of x and transforms it into a y value. You could also have z = f(x,y) which takes a pair of x and y and transforms it into a third value.

A function in C or C++ can only return one value. Therefore we have to resort to "trickery" to get more than one thing back. It would be like if we had y = f(x) in mathematics which would not only return y, but would also change the value of x for the next time we needed …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If the directory structure is the same in 7 as it is in Vista, probably in the c:\Users\<Username>\AppData folder. (But see http://www.vistaheads.com/forums/microsoft-public-windows-vista-general/230161-whats-difference-between-appdata-local-appdata-roaming.html#post814489 about whether it should be in the roaming or local subdir). I'm not sure of the way to get this information programmatically, though.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why didn't you continue this thread?http://www.daniweb.com/forums/thread294268.html

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You didn't take any of his advice except for inserting the include and the using statement. You need to change lines 11,20,27 to reflect string variables instead of the char array and the two char * values.

You need to also change 13 and 47 to doubles.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to take a step back and look at your objectives. If this is for a course assignment which has the express purpose of teaching you how to write a doubly linked list, then no. Use that example you found as a guide and nothing more. If you are looking for an effective list implementation for another piece of code then definitely use the STL container.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ok, I'm not sure if when helping people figure out their code if you actually copy, paste and attempt to run the code, or if you just look it over, so I am going to explain what I have done and what the error is now.

If it's a compilable piece I usually try to run it, or if it's a function that I can couple with a small main to test.

The whole idea that tesuji was trying to show you would eliminate the need for 2 separate file openings:

while(inFile>>next)
{
   total+=next;
   totalsq+=next*next;
}

ave = next/counter;

Then use the formula on line 14 of tesuji's proof. ( sum(xi^2) is totalsq ).

Your problem with your current code is on line 52:

while (inStream >> next);
Griff0527 commented: Excellent at guiding in the right direction while making you think for yourself. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry, even a phrenologist is allowed to make a mistake.

Yes. It's an aperiodic event when it does happen :)

Unfortunately, your implication is incorrect.

Granted. Apologies to the OP.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For Example Suppose we have arr[10]= {2,4,7,3,7,8,1,7,3,1};
and file1 have elements 1,4,7,8,10 and File2 have elements 2,3,5,6,9.

Arrays have a starting index of 0, so you'd have to subtract 1 from these numbers to get the actual index.

Read the numbers from your first file into an int array X, and use X[0],X[1], etc as the index of your arr[10], so arr[X[0]] would be the element corresponding to the first index listed in the first file. Do the same for an array Y read from the second file.

If you're not clear on file handling there are probably dozens of tutorials out there. Here's a good one: http://www.cplusplus.com/doc/tutorial/files/

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Standard dev is Sum((datapt - mean)^2)/(counter -1) so you can't add the squared data and then subtract the mean squared unfortunately since there is a cross term of -2*datapt*mean when you square it out. You need to hold all the data then calculate the mean, then do the calculation.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The only code i found that could help me is here. Is it proper to be used in my case? Do I have to do a separate class for the list and for the node or can I define the node in the definition of the class?
Sorry for the question and thanks in advance!

Yes, that will work, but don't just copy their code you won't learn anything. Where you define the node and whether it is struct (all members public by default) or class (all members private by default) is not critical. The notation will be virtually identical.

This title is so inappropriate...

Yes that's true, but there's no way for the OP to go back and change it. I agree there would be lots of better choices.

kaydee123 commented: goood +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can still wrap a class around for your list and have the struct be a member of the class.

A doubly linked list means that you have the pointers for the next and the prior node. It makes traversing the list easier, as going in reverse in a singly linked list requires keeping track of where you've been. I'm not sure what you mean by "What is the difference in the programming language?"

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Will each operator be a single character? If so then you don't need the template. A templated list is handy for use with a bunch of different data types (say you wanted a node to hold either a double or an integer) but it just complicates your task right now.

struct node
{
    double number;
    char op;
    node *prev;
    node *nxt; 
};
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why do you need a template at all? Can't your second member be a char to hold the operator? (or do you have more than '+','-', etc?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It was in the second link I gave you: http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding . There's a lot of power in these APIs but there's a steep curve in the beginning.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The last poster on that thread before the problem was causing trouble in C also, so there may have been something nefarious afoot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It works now but I think a mod fixed it. I experienced the same problem (in FF 3.6.6)when I went to check on what cwarn was talking about.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use the .is_open() method on lines 16 and 38 rather than fail. Fail is something different like for example if your stream is trying to read in doubles and it encounters a letter in the file (there are other situations that this arises in too). See http://www.cplusplus.com/reference/iostream/ios/fail/

Also, you could just read the data into an array (as long as it's not overwhelmingly huge) and do both of your calculations off that (unless you assignment precludes this).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The code you have posted is not the same as the one you compiled. C++ is case sensitive for variable names so Std:: isn't std:: (you need the latter). Also, rather than being end1 (number one) its endl (letter l). Again, both of these seem to be correct in the code you posted so you must be compiling something you typed in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why are you calling the function on line 12 before you have values for both a and b (you just end up with whatever garbage is in b to start with)? If you cout the return of the function all you will get is your zero you return at the end of the function.

Your function sends in a reference to each of the parameters. This means the function not working with copies of these variables, but the variables themselves. When you pass in a and b into the function (which become x and y just by virtue of your naming) from main they are squared and written back to themselves. The changes persist after the function has returned. So eliminate line 12 and 15 and cout a and b on line 15 instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not familiar with the objective-c syntax, but in C++ it would be something like

void func2(NSScanner * myNSScanner)
{
   //yada
}

void func1()
{
   NSScanner * aScanner = new NSScanner(); //or your parameters 
   func2(aScanner);  

}

It's different from the integer example because your aScanner is already a pointer

(You could also pass around a reference to your object (using the & operator instead of * in func2 -- just pass in a NSScanner object to the function directly you won't need the pointer))

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Law of cosines (http://en.wikipedia.org/wiki/Law_of_cosines) will help you get the angles between all of them.

I would test for the right triangle that way rather than your method (especially since your values a,b,and c are doubles and comparing those for equality is tricky (since a number close enough for practical purposes will not be equal, 1.0001 != 1.0).

If you are going to use that Pythagorean approach some of your formulas are off if a^2+b^2 = c^2 then a^2 = c^2-b^2, etc.

StuXYZ commented: rep. for the double comparison educational outreach +3
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here are a few links:

Specific to what you were looking for:
http://www.stevetrefethen.com/blog/UsingGoogleMapsforGeocodinginC.aspx

Google's reference for geocoding
http://code.google.com/apis/maps/documentation/geocoding/

How to get an account and use the RESTful services
http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html

I've used a similar API with Netflix but I haven't used the Google one in particular. Those links should get you started and give you some other search terms to try.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Jonsca: oh, do you mean removing non-alphanumeric characters as preprocessing ?
I can think of using STL strings & equal() algorithm .. any other ideas, please?

Yes, you need to pull out the apostrophes and commas, as they are not at the same position forwards and backwards.

STL strings will work with an iterator or an STL algorithm like reverse().

Are there any other STL containers that might be ideal for this? One that might help you reverse something?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A hint: moving forwards and backwards and comparing will not yield detection of a palindrome in the strings you have there. You have the right idea you just need some preprocessing first.

Can you think of any other efficient ways to do it?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Combine them into one procedure:

Are any of them equal to each other
    Yes: Move to next step
    No:  Is the first the largest?
         Yes: Set largest to first
              Is the second greater than the third?
              Yes: Set smallest to third

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

If you leave the average as an integer you will lose the decimals. That's what I was saying, if you have 1 + 3 + 4 = 8/3 = 2.6666etc will become 2

You have the average incorrectly in your code as the product/3. It needs to be the sum.

I'm checking for the sake of your sanity, I'm assuming this if/else bit is specified in your assignment. If it isn't you could get the whole thing done in just a few lines (fewer with a for loop).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A couple of things to check:
What is the definition of average? You do not have the formula correct.
Secondly, if you have the numbers 1,3,4 (for example) will your average be an integer?

What you are neglecting in your if/else cluster there is that you can test for more than one condition at a time, e.g. if(firstNum > secondNum && firstNum > thirdNum) will cut down on the number of steps. Your specification only asks for the largest and smallest, so if there are two smallest it doesn't matter which is which (at least in my opinion, your instructor may feel differently).

For the flow charting, just go through the steps of your if/else and write them out on paper noting the different paths, make branches off of the earlier tests. For the other portion with the sum, product, and average the calculations can probably be listed as a single step (plus an additional step for the average from the earlier result).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

As long as they have all of the dlls that they need, you should just be able to run the exe provided you compiled it for their platform (so if you're on Windows and they are on Linux you'd need to compile a Linux binary). If you are using Visual Studio your friend will probably need to have the Visual C++ redistributable installed (http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en is the one for VC++ 2008 but there are versions for 2005 and 2010(forthcoming) as well).

If you've written an application that has a lot of dependencies you can package it all up into an msi to have a full-fledged Windows installer. You can use something like Wix for that (it might require the full version of Visual Studio, I have never used it).

Hopefully that covers what you wanted but if you go into more specifics it will help narrow it down.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Another excellent reference is http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13 (it has a ton of info on template classes too).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

" boost/timer.hpp: No such file or directory. "

You'll need to download and build the library from http://www.boost.org/. Some of the facets of the library can be used with just the headers (as they are self-contained) but you'd still have to make sure you had all the dependencies (the headers include other headers, etc.). I'm not sure what the case is with Timer.

See http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html (or if you need the *nix version it's the next page in.

It may be painful to install and get working the first time

I found this to be true also, but if it's what you need then go for it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You'll need to create a "node" class or struct that contains a data member that's a std::string (or a char *) and 2 pointers, one to the previous node and the other to the next node.

I was more asking what you had tried in code. There are countless examples of doubly linked lists on this site and on the net in general. Google for some samples.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What have you tried so far?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is a good overall reference: http://www.cplusplus.com/reference/string/

Your function would look just like this (omit the std:: if you have a using directive):

std::string enterPass()
{
    std::string pass;
    cin >> pass; //provided no spaces, otherwise use getline
    return pass;
}
in your other function

void Passfunc()
{
   std::string password;
   password = enterPass();

  //etc.

}

You can write a std::string right to another one without using strcpy and you can compare them to each other with != == etc. instead of strcmp.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I know you want a binary file but just to make sure it's going where you think it is write out a text file with a particular name and find it in your file structure. Either that or try to write something into the binary file before you close it, there may be a mechanism in place not to create it if empty.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your function is designated to return a single char and "pass" in passFunc is declared as a char array. There's a mismatch there.

These errors don't include that you are trying to return a single character (perhaps thinking you are returning the char array) from your enterPass function that is one past the end of the array (arr[11] has elements 0 thru 10). I would say the best thing to do would be to have your function return a std::string. Makes things nice and easy.

You're going to have some trouble with displaying the stars because all of the standard library functions will echo your input. There's a platform dependent way to do it with getch I believe but I don't remember exactly how.

Also, a bit off topic, but it seems like you have ditched your VC++ 2010 for the Turbo again -- how come?