jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So what is the exact error message that you are getting? I can't repro because we don't have those other two header files (I assume they only have class declarations and are not part of a greater library). Your commented code seems logical at first glance.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hopefully you found it in your code, but the midpoint on an interval from a to b is (a+b)/2 not b. And the opposite signs should be at the ends of the interval, so line 61 should be if(f1 * f2 > 0.0) since the sign criteria is showing that from one end of the interval to the other the function passes through zero.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Scott has written the functions outside of main. Remember main is in and of itself a function (method really).
In the code, you close off main() with } and then give the function _definition_ with return type, parameters, etc.
Your _declarations_ (yes you do need all the ones Scott put there for the overloaded function as the definition of overloaded is having a different signature (the types and count of parameters) from other "same name" functions) at the top tell the compiler "ok, these functions are somewhere and they take these parameter types, so look for them where you usually do."
This is how you can include a header file (which usually contains _declarations_ among other things) but not have the functions in your code.
Not sure if that clarifies it or makes it worse. I'm hopeful for the former.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can import with P/Invoke
http://msdn.microsoft.com/en-us/library/aa288468(VS.71).aspx
or you can write it in "managed" C++
http://msdn.microsoft.com/en-us/library/aa712574(VS.71).aspx
also, this question comes up a lot at
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/threads
(this is one of their niche issues).
And no doubt there's lots of folks lurking here that may know a thing or two about it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

LoL oh well. *Gets in time machine to not post this thread in the first place. Thinking about it, I, by and large, read new(er) threads. Sorry again for taking up your time with this then.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Dang, I'd only seen the this thread is closed message.
I was hoping "they" would put something stronger in place because I can't stand the 4 year old nicely resolved and already complete threads with the "I want the C++ codez for [canonical pedagogical program here]" tacked on the end of it.
Well, my apologies for being a "day" late (and definitely a dollar short) on noticing that (but maybe it's good cause I got to air my grievance about resurrected threads).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is for SDL but the principles are more than likely the same for anything you will run across.
http://www.noquarterarcade.com/setting-up-a-codeblocks-project-with-sdl-on-windows
Scroll down about 3/4 of the way to find the heart of it dealing with the search directories for the compiler and linker.
Now that the project has all the proper search directories, include your header and it should search those paths to resolve any symbols during the link.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is that "this thread is over three months old" warning new(it's possible I totally missed it before)? Either way I like it!!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A few things, it's shaping up :)
1. Switch blocks cannot take multiple characters, they only accept 1, so have the user enter in 1 letter or determine another method (e.g., if-elseif). While you are fixing that, move the code that you use to prompt the user after the case is decided (e.g.lines 54-56) outside of the switch block and just leave in the sumItem statement.
2. When calling a function you always need parentheses whether or not there are any parameters (so for line 36 should be displaymenu(); and I suspect for the others in that group as well).
3. The while on line 134 is not doing anything. If there are multiple statements under a while (or for, etc) you need to put them in braces {}
4. You have the idea with the while loop, but I think you need two of them, one inside the other, one for your menu system and the other for ordering the food

While (number !=3)
{
  Menu Display here
        
          while(response=='Y')
           {
                   prompt for orders
                   another item? (enter Y)
             }

}

So again, it seems like a lot but it's just a little shuffling around and then you'll be on your way

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What error is it giving you?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You could have one array[10] of strings that holds the name and another array[10] that holds the averages that come back from the function. Then just iterate to 10 with a cout that displays both name and average.

Encase the whole of main(minus your array declarations) in a for loop (or if you wanted to verify input use a while).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Unless you are doing something with real time OSes (http://msdn.microsoft.com/en-us/library/ms838340(WinEmbedded.5).aspx), and even then it's impractical, it will be obsolete knowledge. inp/outp used to be great for interfacing with fixed address ISA cards. If you're interested in this kinda thing check out the DDK (http://www.microsoft.com/whdc/devtools/wdk/default.mspx).
Not to be a wet blanket about it, just offering some advice.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
#define MAX 999   (no equals)

And you create all_names out of nowhere in two of your functions

It doesn't really matter _that_ much, but this is more of a C program than a C++ one :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

how is the size of AllianceCharacters[] determined? You probably need a "new" statement to instantiate the entire array (in addition to its members, which you have done in your method)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you try changing the while condition?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How come you named the other parameters of the function? So you can use them in the function body (among other things).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, cause then your program breaks, completely. You need to pass in an array to accept the "amount" in that slot (your function doesn't even assign your amounts to an array like it should), as that array is passed into your output function. For what ever reason it compiled that way but it almost shouldn't have.

In other words, stick a name on that float [] and use it in your function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I agree with Clinton about the b=a thing. I personally think I need another example as to which is which value, but on the surface I think you might need && instead of || in your while loop. You want to make sure if either one of the conditions isn't true than stop the loop (while loop is "on" with a true value).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Passing an array e.g., func(type a[]) is equivalent to passing func(type * a) anyway, so you already had the pointers working for you. I'm taking a look into whether you may have swapped one of your arrays.

EDIT: Found it, this is within your definition: float calculateGrossPay ( char ps [ ], int input [ ], [b]float [ ] [/b], int size) so in the end you were getting whatever garbage was in stoodence3 upon declaration.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Apologies, that url I gave you was for the version of curl that works within PHP. There are quite a few samples in C/C++ there:
http://curl.haxx.se/libcurl/c/postit2.html

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I wouldn't bet the farm that this will work for you (as in I don't know) but this is a popular library that is directly involved with web type traffic, works under C++ and interacts with PHP.
http://curl.haxx.se/libcurl/php/examples/

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Parent class functions that need to be different than their parent class counterparts must be labeled virtual. This lets the compiler know that the method will be attached dynamically (i.e., depending on the type of the object at runtime). If I have a class called hasmotoroutside I can derive and create a car and a lawnmower from it, which can both be stored in a garage (or an array of hasmotoroutside objects) but when it comes to the start function of hasmotoroutside, it must be virtual because in the mower it consists of pullcord and the car it conisists of turnkey.

So really all you have to do is declare your virtual function with that keyword. It's important for things like destructors when if you allocate memory in a derived class you sure don't want the compiler to leak that memory if the parent's destructor were to step in.

Just remember the underlying assumption to all this. An array can hold objects (or pointers to objects) that have the same base class even if they are of a derived class.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, the way you have your for loop set up to see at which property the player resides, you are perhaps moving it to the last property regardless of where it started. Perhaps once a move is made you should break; from the for loop and proceed on to the next turn.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
std::ofstream output(name.c_str(),std::ios_base::app);

would be the only modification. I'm just confused since you did modify the code to output hello in that function. That's the only way I can think of but perhaps someone has a better method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I may be incorrect, but since they are multidimensional arrays, the (a+i) value should be a pointer to a pointer (to a dereferenced element with the []) so it's a pointer indicative of the 0th, 1st, or 2nd "row" and then the given index in [] should be the offset into the that row.

And the reason you don't need the sizeof is as you said, the array has been declared with a specific datatype.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You shouldn't be calling main() like that. In your main() turn your menu into a while loop and call your functions from within. In your function (edit) when the user hits q, just use return; to go back to main.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Wow that's like a 3-way tie there...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Pop int Counter::nCounters; at the top of your counter.cpp file.
http://www.cs.loyola.edu/~lawrie/CS301/F03/StaticClassMembers.htm

Also, you don't need to include your cpp file in your h file.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

He/she is addressing the 3x3 array members by pointers and setting them to an intermediate variable so that when the input is written to said intermediate it will be written into the array. I agree with your point I don't know what prohibits setting a[0][0] to a value directly, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Firstly, this is not a code snippet, code snippets are for things like I have a tried and true function that might benefit the community (or many other related matters but not in general homework).

I'm not super sure why you couldn't assign directly to a[3][3] from input.

cin>> a[0][0] >>a[0][1] >> a[0][2];

I also don't know why you are passing in zerozero to your function as it in and of itself is not a pointer to your whole array. Just pass in a . In addition you are only performing your function calculation on 1 single element before you return. If you want to return an entire array, you could just pass a by reference instead of returning a double (in reality you are passing it by reference here but just not doing anything with it back in main)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think you want the opposite of your current flag condition. Set the swap flag condition to true. If you're swapping the loop should continue until there are no swaps. So, inside your if clause of the for loop, have swap set to false.

Also, unless you have an overloaded operator << you can't just send an array to the output stream like you have it in the end of the function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just need to declare count and total, count which you can do in your for statement: for(int count =0;count<numStudent;count++) and add int total = 0; (outside of your for loop, at the top of the function). Reread the stuff in your text on function scope to see how these variables are created and why they are isolated from the ones in your main function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Count is not defined in your function as a function has its own scope. Redeclare int count in your function body. Also, you pass in an array called list and you are using the one called student (also not in scope). Within the body of your function you should change students[count] to list[count].

When calling the function use getAverage(student[],numStudent); note that the numStudent in main and the numStudent within your getAverage function are two totally different things. You could pass in an int called studentNum or anything else as long as it's an int.

Note also that your function does not return anything so you should either give it a return type (e.g., double) or display the value before your function exits.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I made a couple small changes to make sure that we are only updating hangman for wrong guesses. This works on my machine.
(ignore the strcmp_s change,it's a good idea...I was compiling on another sys initially)

#include <iostream>
    #include <windows.h> //has sleep function
     #include <string>
    using namespace std;
     
    void DrawBar(int guess);
	
    int main()
    {
        char solution[8]; //holds solution
        char blank[8]; //holds "*"'s for unsolved letters
        int counter = 0; //general-use counter
        int right = 0; //1 = right guess, 0 = wrong guess.
        char guess;
        int word=0;
	bool found;
        cout<<"Enter phrase 8 chars or less."<<endl;
        cin.getline(solution, 8);
        int puzzLength = strlen(solution); //finds lengtrh of puzzle, stores INT value to puzzlength
         
    //convert puzzle to full uppercase
    for (counter = 0; counter < puzzLength; counter++){
       solution[counter] = toupper(solution[counter]);
    }
    //done converting
      
    strcpy(blank, solution); //copy solution to the 'blank' array
      
    for (counter = 0; counter < puzzLength; counter++) { //converts characters to _'s to represent blanks
      
       if (isalnum(solution[counter])) blank[counter] = '_';
	   
 
       else blank[counter] = solution[counter];
        
    } //closes for loop
        
    while (strcmp(solution, blank)) { //play game until the 'blank' puzzle becomes the 'right' answer
       
    cout<<endl<<"Solution phrase is: "<<solution<<"."<<endl;
    cout<<"The current 'blank' puzzle is: "<<blank<<"."<<endl;
    cout<<"Enter a guess."<<endl;
    cin>>guess;
    guess = toupper(guess);
         
       
    //cbeck guess!
    for (counter = 0; counter <= puzzLength; counter++) {
        
        if (guess == solution[counter]) {
        blank[counter] = guess; //fill in the puzzle with the letter
        found = true; 
        }
	
        } //close loop, done checking guess
         if (!found)
		 word++;
	 found = false;
	
	DrawBar(word);
	if(word >=5) break;
        } //game is over.
         if(word …
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you change both the declaration and the definition of DrawBar to void DrawBar(int guess) ?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would do it within the while loop after the for loop.

You have it after the whole thing is over. That does you no good.

//cbeck guess!
    for (counter = 0; counter <= puzzLength; counter++) {
        
        if (guess == solution[counter]) {
        blank[counter] = guess; //fill in the puzzle with the letter
         
        }
         
        } //close loop, done checking guess
         
	word++;
	DrawBar(word);
        
        if(word >=5) break;
        } //game is over.
         if (word >=5)
             cout <<"Lost"<<endl;
         else 
              cout<<"Winner!";
        cin.get();
        return 0;
       }

declare word at the top of main

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Does your function have to be void? If not change it to double and do return average; To fix it as is:

cin.ignore();
for (int i=0; i<5; i++)
	  {
            
            cout << "Please enter grade" <<endl;
            cin >> grade[i];
	    sum= sum+grade[i];
	   }  
                 average = sum/5;

Your name input was mucking up the input stream.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It has nothing to do with guess. Don't mess up the working part of your program. At the top in main() declare int guesscount; After your for loop for(counter =0.....) we've made one guess, so guesscount++; (make sure it's outside of the for loop). Next, call DrawBar(guesscount); However, you'll need to put a condition for greater than 6 in your drawbar because what if it takes the user 6 guesses or more? As it is the program will bypass all of your else if statements.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would do it within the while loop after the for loop. Why would you change guess, you need that to be a char. Declare a new int, increment it (++) at the end of the while loop and then call DrawBar(countervariablehere). That way your user knows their status after they've made their guess.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Exactly. You just want something that's going to keep track each time through the while loop so you can register what guess your user is on.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Actually, take the final average calculation (average = sum/5) _outside_ of the for loop otherwise you'll be calculating it each time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I believe you want this as your second parameter in your ofstream object in your CWrite function std::ios_base::app

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

http://www.cplusplus.com/reference/iostream/ofstream/open/
Specifically, take a look at the mode option for append.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nope, just have an int that increments with your while loop. You'll have to decide the best place to call DrawBar as it could be reflecting the status after this present turn or showing the user their status before the next guess.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was initially thinking to tell you to use a foreach (should look them up anyway they are useful) but since you are accessing the next element in the list it's not a valid option. properties.Count will give you the information for the size of the list so you can use that in a regular for loop. You're not doing any list editing in this loop but the need to remove items mid-loop is another reason to stick with the regular for loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're passing a char into your DrawBar() function which is incorrect. Keep a separate int counter to keep track of your guesses and then give that to Drawbar after a guess. You'll never be entering in the characters '1' '2' '3' '4' '5' as part of your alphabet guesses so there is no sense using what would be nonsense anyway.

Also, next time please think of a meaningful title for your post. Not meaning to single you out, but I wanted to say something. It takes 2 seconds and believe it or not people are much more willing to help when they can see what they are getting into.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take in 2 doubles from the user and then use your constructor to create a new object.

double r,im;
cin >> r >> im;
complex num(r,im);
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think your || should be && cause 89 is greater than 60 so it short circuits and you get anything over 60 as a D.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also in your function max should equal grade not max+grade.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In main set max = findMax(grade); I had missed that before, but if you don't have a variable to return your function to the value is lost.

All of your post editing is getting confusing I'm not sure where you are in the chronology.