jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's not what I got, I just tried it you run off the end of the array. I had along the lines of copy[i] = copy[i]+ (A[(i % cols)+(j-1)*cols])*(B[(i/cols)+(j-1)+(i+1)%cols]); Since the i value is the same you don't need to change that first array indexes at all but you have to follow that 2/3/2/3 pattern for the second array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
struct addressbook personaladdressbook[50]
{
  char name [NAME];
  char address [ADDRESS];
  char phone [PHONE];
  char email [EMAIL];
  char Target[NAME];
} addresses[NUMAD];

With this we've confused you a bit, remove both additions from this block. To instantiate a struct do either:

struct mystructname{
//members here - left out for clarity
} mystructarray[50];
and nothing in main

-or-


struct mystructname{
//members here
};
and then in main()
struct mystructname mystructarray[50];

If you make it in main, you're going to have to pass a copy of the struct into your methods (and keep track of the number of entries out in main). If you make it in the first way the array of structs is global and you can access it directly. The first way is probably neater and preferable.

However: I'm looking back over your code and noticing that you aren't really trying to keep an array of the names and addresses at all. It seems like you might not even need the struct. If you need to keep it as part of your requirements just put:

struct addressbook{
//other members here
}myaddressbook;

and rename all of your references to addressbook in Insert() etc to myaddressbook. Apologies we got you going on this array route. I just didn't understand that all you were doing was populating the struct and then writing it out as raw strings anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a closer look at your index on your b.data_ vector on line 15.
The pattern that you have is this:

i,j,index of A,index of B
0,1 0 0
0,2 2 1
1,1 1 0
1,2 3 1
2,1 0 1
2,2 2 2
3,1 1 1
3,2 3 2

Now if you go through the calculation by hand that's not the right order for the i = 2 and 3's (it happens to work for the i = 0 and i = 1 cases)
For those you need something like this:

i,j,index of A,index of B
2,1 0 2
2,2 2 3
3,1 1 2
3,2 3 3

See what you get for the equation and then we can compare.

Also, you need to clear copy before each time you go through the js, that's why your answers were so high.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Firstly, presentation is paramount. Please wrap your code in code tags. Use the edit button to edit your post.

[code]

/*code goes here */

[/code]

You may be frantic but there's no need to panic, this is a solvable problem.
I haven't run your program yet but there are a few issues.

Why are you using your own prototype for strcmp at the top? There should already be one in string.h. Also, when you call it you have strcmpi. There's a such thing as stricmp (for case insensitive comparisons) but it's not standard.

Also, you presumably pad your yes and no strings with extra spaces so they are guaranteed not to match up with whatever you enter. char yes[] = "yes" will do.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

but what I have here completely makes sense..

To you maybe, but it doesn't work for the compiler. The other poster was correct.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Thread closed means no one can post on it anymore, it doesn't say anything about the forum. Aia just wanted you to read the information that was there.

You haven't done any irreparable damage (at least not in my book) but it considered quite rude to "bump" your thread up and especially so after such a short amount of time in between. The wonderful thing about the reaches of DaniWeb (and the internet in general) is that the person who solves your problem may not even be awake yet.

Meanwhile, I would look for individual sites that have material that you think is pertinent rather than looking for a monolithic tutorial that has everything you need. You might want to look at some of Narue's tutorials (http://www.eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx) there's some information there that's only pertinent to C++ but it's quite clearly marked as such.

Aia commented: Outstanding. +8
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It doesn't do anything the way you have it. That's not what AD meant.

Matrix::Matrix(int mdim_, int ndim_)
{
  this->mdim_ = mdim_;
  this->ndim_ = ndim_;

is very different than what you have there. This is saying take in two arguments mdim_ ndim_ via the constructor (which happened to have the same names as your internal variables but don't have to be) and set them to this->mdim_ and this->ndim_ (which are the internal variables). This way everything is initialized. As gashito reinforced there are variables left uninitialized the way you have it set up now.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Question:

mdim_ = mdim_;
ndim_ = ndim_;

what is the point of this? It doesn't affect your problem but it seems prone to error and completely unnecessary.

Which leads me to the next point of: look which constructor your are calling, the one taking columns. What is the ndim_ in that case? It's the same value as the non-initialzed ndim_ which is holding garbage.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are two options, neither of which will be a quick learn unfortunately (certainly that depends on the amount of time you are willing to put into it). The express edition offers you two options for doing GUI. The first is Win32 API which is quite powerful but can also be unwieldy as well. A good starting tutorial for that is http://www.winprog.org/tutorial/. The other option is to use the Winforms (.NET) via CLR (using C++/CLI). If you are familiar at all with .NET programming from C# or VB this may be easier, but you'll have to rewrite at least some of your code for this particular dialect of C++ (strings are quite different). There are other options available. Were you to have the full version of Visual Studio you could use MFC which is more tightly bound to C++. Options outside of the Microsoft world which are free in one form or another are Qt and wxWidgets.

Not the answer you wanted to hear I know. Post back if you have any questions of course.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put some cout statements in strategic places and figure out exactly where it is crashing. Also, reread what WaltP has written about going out of bounds on your array. I would pull in those variables from global scope on 8-13 and work them into main. Global scope causes too much confusion for that to be helpful. Pass what you need to between functions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I went and tested it out. Usually you can right click on the terminal window and it brings up the context menu, but I had to go up to the upper left hand (system) menu, go to Edit, mark, highlight it, hit enter (that part I remembered correctly). Then you should be all set. I know the ctrl-c ctrl-v is convention for most things but this case is different.

The cin.get() only serves to hold the screen from closing it has nothing to do with the copy/paste.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hitting enter finishes the copying process. Put something like cin.get() at the end of your code to get a pause effect so that you'll have more time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So , is it means that software engineering will include programming ?

More than likely but like Salem said Software Engineering is going to teach programming as a means to an end and may teach important concepts independent of language. The overall picture will probably be more theoretical. That doesn't preclude you from taking more programming classes as electives or as part of a second major if that's allowed. You can always pick up more languages on your own or via an online course but it's more difficult to teach yourself SE because a lot of it is (more than likely) project driven. Check out the websites for programs that you are interested in they should tell you the requirements in excruciating detail.

Salem commented: Yes. +19
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try changing line 32 to while(inFile >> inValue) and remove line 33.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hotdogstand is your class, so it's a type. It's not int Hotdogstand[] it's gotta be of type Hotdogstand[].

void HotDogStand::JustSold(int DogCounter, int numCarts, int HotDogStand[])

should be

void HotDogStand::JustSold(int DogCounter, int numCarts, HotDogStand CartSales[])

and you have to pass in CartSales (no brackets) when you call the method in main(). Note that the parameter of your method JustSold could have been HotDogStand myHotDogStand[] (any name here) it doesn't have to match with the variable in main, just the ones within JustSold itself.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I already know about Borland.

I kinda thought you would've but since it came out after TECO I figured it was worth mentioning. :D I'm not expert on Dev either but I'm fairly certain that the gcc doesn't have it in the libraries (and I went through this with another poster trying to find an alternative).

The solution ends up being a library like pdcurses which has equivalent constructs.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

finds the last whitespace in that substring

Overlooked that bit, apologies.

string Formatstring(string input,int length,string suffix)
{
     string tempstring = input.Substring(0,length);
     int lastindex = tempstring.LastIndexOf(' ');
     return (input.Substring(0,lastindex)+suffix);
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need the delay function, use a timer. Drag one over to your form from the ToolBox (or create it in code). Place your Move_circle method into the Paint event of the form. Within your timer call Invalidate() with each cycle which will invoke the Paint method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

if (next == '#N#') '#N#' is not valid. Single quotes are for a single character (but can hold escape sequences like '\n' for newline). Make next a string, use a getline to read it in and then compare it with "#N#" instead.

Also, don't use feof. Use your getline(fin,next) (see first paragraph) to drive the loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I draw the "background" first (in this method), and the foreground changes

The difference is twofold. First, your background (I'm guessing) probably requires a lower refresh rate. This way you can update the background only 3/4 as often or whatnot and give some of the performance to your foreground elements. Also, each timer is in its own thread. That may be one of those "for better or for worse" kind of situations. See this about having 2 timers work together.

I'm not familiar with InvalidateRect but the information I found on it would lead me to believe that you can specify a region of your window to invalidate (like if you had a rapidly changing region and perhaps didn't need to repaint the rest of the scene as often). Analogous to the way Invalidate() calls the Paint method of the form in .NET, InvalidateRect works at a more fundamental level. I don't know the details. It's a Win32 function so it means you'd have to use DllImport with it to use it with .NET (there's a MFC version too but that won't help you in this instance).

Take a look around about double buffering. I don't know the answer to that one. I know that Panel doesn't have a double-buffering property to change but I don't know whether it falls under the blanket of the entire form.

I wish I had more information for you. Poke around in the C# forum archives for the answers …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On line 43 initialize it as char ans = 'n'; (or anything else besides 'y' really). Since ans is not getting a value except for in the default case of your switch block it's entirely possible to go through that without getting a value for it, therefore it doesn't know what to use.

EDIT: Adatapost is suggesting to set it to 'y'. My suggestion does not contradict that but I assumed that you'd want to default to going through the loop once if the choice was not presented to the user (rather than going around again).

sourav_kings commented: cool +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

choice is local to the method it's declared in. However if you declare a variable choice in main (it could be called anything really I was just matching it up with your switch statement) and use it like choice = Menu(); Then it will display the menu and assign the option chosen to the variable choice back in main.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What I meant was that if you wanted to step by +1 for your loop that you could do 10-m so for 0,1,2,3 it would go 10,9,8,7 but CP's method is more straight to the point.

So what do you need on the code you have just posted (not sure what happened with the code tags it seems like they skipped)? For the + sign (surprise) you need the nested for loop again. Spaces can be used to your advantage, plot it out on paper. I'm not sure what kind of error trapping you are looking for.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ok, so you want the second side to be at the top rather than the bottom?
****
***
**
*
(I'm assuming)
So for your second loop say number was 10, you'd want to have rows of length 10,9,8,7... (with the m=0, (ignore the stop condition it's not correct), m++ your loop would be going ___? (from what to what).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The best way in your case (with the .NET) is to create 2 timer objects, one for the "background" animation and one to pace the foreground changes.

You can have two methods, one in each of the timers (one for drawing the foreground elements and one for the background) that makes all the necessary positional changes and then you can call Invalidate() at the end of the timer_tick event.

Also important is to go to the properties page of the form and make sure double buffering is set to true.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you adjust your function's signature to: void addNames(ifstream& fin, ofstream& fout) (the parameters used in the function body must match those in the signature)
you can avoid the global variables.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I keep getting "program has exited with code 0"

This is referring to value sent back via the "return 0;" at the end of main not to any result in your program. In the past (and probably still currently)people have used different error codes to signify different events causing the program to exit this is why the IDE is reporting this to you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Aside from all the rest of the situation you've got semicolons after your for statements. The loops definitely won't run then.

Just my $0.02, sit down away from the PC with your text and study the for loop because you're just going to frustrate yourself at this rate. I'm referring to things like for (triangle = 0 ; symbol = ' '; number++) . The second position there is evaluated as true or false and if it's false the for loop stops (hint: that will never be false).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

(fill in the name of your own output file for outFile)

Was incorrect, my apologies. I had meant to say the name of your output filestream for outFile.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try this:

#include <sstream>
string filename;
stringstream ss;
cin >> filename;
ss<<filename<<".dat";
outFile.open(ss.str().c_str());

The first str() gets the string from the string stream and the c_str() you already know.
(fill in the name of your own output file for outFile)

After further consideration I'm not sure why CP's solution would not work. What was the specific error you were getting?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It looks ok. I'm confused as to why you are incrementing and decrementing playerTurn in the branches of the if.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In the first case up above it would be rects[i].getWidth() but in the second case you'd have to downcast it like

(go[i] as Rectangle).getWidth()
or 
((Rectangle)go[i]).getWidth()

of course in all of the above cases i is the index for which you are looking.
Also, if you just had a plain old Rectangle object Rectangle myrectangle = new Rectangle(0,0,10,5); you could access it like myrectangle.getWidth() which is close to what you have there but unless the getWidth() member is static you cannot access it without instantiating (using new to make your own object).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

All you've done there is put the names into a string array. I think what you mean is if you had the class Rectangle, you could create an array of rectangles by saying

Rectangle [] rects = new Rectangle[5];
rects[0] = new Rectangle(10,10,1,1);
rects[1] = new Rectangle(5,5,1,1);
etc.

(just made up a constructor signature there)


Now if all your classes derive from GeometricObject you can create an array of GeometricObjects and store any of the derived shapes in there.

GeometricObject [] go = new GeometricObject[7];
go[0] = new Square(10,10):
go[1] = new Triangle(0,0);
etc.

(also made up constructor signatures)

I believe these objects in the container (those derived of the parent class) can be downcasted to access their members but I am not 100% sure when this will work (I have excluded the GeometricObject since they cannot be downcasted safely).

kvprajapati commented: I like your approach. +7
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Variables must be declared at the top of the block. Move your declaration above the printf statement.
Also, you have an extra semicolon on line 61(EDIT: Though that seems to pass through ok, I guess it's optional).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Could your professor have meant something like disabling them as well? That was the first thing that came to my mind, but maybe that's oversimplifying it a bit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where on earth did int mainMenuSelection(int); come from? Looks like a function prototype to me.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Congrats on making a decent effort on what we had talked about in the other thread.
However:

array monster [level 1 , 100 health];

damage ++ 1-10;

you're still making up syntax as you go. It would be the equivalent of me walking up to you to have a conversation and saying "Car nematode went see down global equivocally dentist." It's kind of grinding on the mind to read.

Look up rand and srand to get an idea so that you can say something like energy = energy - (rand() % 35 + 1); which will reduce the energy between 1 and 35 points. Use srand() once in your program to seed the random number generator.

dusktreader commented: "Car nematode went see down global equivocally dentist." -> classic! +1
Nick Evan commented: :) +12
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

some wire strippers

I believe the term "dancer" is preferred nowadays ;)

(I know I know... I just couldn't resist)

Ezzaral commented: hehe +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See, I didn't even have to say anything. :D I think I had started to but got distracted. Don't forget the conio.h too, nice and non-standard.

jephthah commented: heh. my edit and your post passed each other like ships in the night :) +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Step through the code to see:

int main()
{
	double angle=0;       //angle = 0
	double sinAngle = sin(angle);  //sinAngle =  0 at this point

	for (angle=0; angle<=90; angle++)  
		cout << sinAngle << " " << endl;  //sinAngle hasn't changed
	                                       //and won't change so the value ^^^
                                              //is printed 91 times
	return 0;
}

Compare with (skip the other two variables):

for (double angle=0; angle<=90; angle++)  //since you're going by 1 anyway you could use int
		cout << sin(angle) << " " << endl;  //angle is changing each 
                                                                          //pass through

P.S. the math library uses radians so you need to go from 0 to Pi/2 if you want 0-90 in degrees

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You only did the calculation once:

double angle=0;
double sinAngle = sin(angle);

This doesn't magically assign that function to sinAngle, it evaluates it at angle 0 and prints it over and over again in your loop. Leave the declaration double sinAngle; outside and move the sinAngle = sin(angle); inside your loop.

Salem commented: Indeed it does :) +19
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Good luck with it. There were a couple of false starts there on my part but it should be fine now. Post back if you have probs.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Change your while loop to a do/while loop with the same loop condition. Move your prompt for the salesperson number into the loop. That way it's called the first time through and any subsequent times.

Line 20 has the incorrect format specifier for a double, it should be %lf
instead of %d.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This goes very much in depth but seems to have some good background in the beginning. Lex is a specific lexer but the concepts are the same.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Create your own class with + - * / overloaded.

This is an example for matrices but it's similar (complex will be less complicated).

Give it a go and post back when you get stuck (or if you have code already post it and someone can look it over).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I didn't compile and run your program yet, but try putting the srand() call out in main() so it's only done once.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

main should always return an int, not be void.
You need to make x and y reference variables, otherwise you're passing them in and they are changed but this is not reflected in the original variables. void A(Complex a,double & x,double & y)

sleepybug commented: yup..the reference thing worked.;) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Salem
The vice principal who would buy you beer on the side that you never had. Cares very deeply about the quality of the site, keeps people honest, extremely well versed in the C/C++ family (I've caught him in C# before too), offbeat sense of humor. I'm pretty sure he's British but nobody's perfect. Oh yeah and he operates invisibly so sometimes all you will see is the quick drying orange spraypaint in the rep box if you're not careful :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I made the following changes to the TriviaQuestion class, see if substituting this one in helps:

public class TriviaQuestion
    {
        private string question;
        private string answerA;
        private string answerB;
        private string answerC;
        private string answerD;
        private string correctAnswer;

         //properties
        public string Question { get { return question; } set { question = value; } }
        public string AnswerA { get { return answerA; } set { answerA = value; } }
        public string AnswerB { get { return answerB; } set { answerB = value; } }
        public string AnswerC { get { return answerC; } set { answerC = value; } }
        public string AnswerD { get { return answerD; } set { answerD = value; } }
        public string CorrectAnswer { get { return correctAnswer; } set { correctAnswer = value; } }
 //explicitly tell it to get and set the private member variables
    }

You have it trying to pull data out of answerA, etc. when all your getters and setters (the default ones) are capable of is getting and setting the properties like AnswerA, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

a good one is the mesner twister

It's called the Mersenne Twister.

Just a quick note on the cast in my srand call -- srand ideally takes an unsigned int but time comes back with a one that is of type time_t, which is normally a typedef of integer. srand() may generate a warning otherwise.

NathanOliver commented: thanks for the corrction +1