jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What DS means is don't try to return a value, just have a return; statement where you need it. If is not a loop anyhow. What is the specific warning you are getting?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i want to be able to call a function from there to the array of individuals..how would i do that?

I'm not quite sure what you mean by that. Can you give a brief example? (just conceptually)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just my 0.02 but it would probably save you the aggravation in the long run to use a chip programmer. From my cursory net search on it it looks like a lot of the programmers use USB these days so there are some decent device drivers out there. I was looking at this in particular that comes with Windows software but there are probably less expensive options.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Note: this one doesn't mind that it don't forward declare Train, I figure this means it's getting Event.h forward declare of it, or I was wrong in my previous statement saying they're not giving me trouble, I haven't tested them individualy yet.

Arrival shouldn't need it then either then as it's part of Event.h. It's possible that's goofing you up too. Well, try all the suggestions and see what happens.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have not made an instance of your struct like:

struct addressbook
{
  char name [NAME] ;
  char address [ADDRESS];
  char phone [PHONE];
  char email [EMAIL] ;
  char Target[NAME];
} addresses;

In fact you probably want an array of them so #define the number of addresses (say NUMAD) you need and change addresses as above to addresses[NUMAD] or the like. You'll have to keep track of the current count of addresses somewhere so you don't overwrite the information. This way you can have more than one entry.

Another option would be to declare an instance of your struct in main and pass that into your functions.

Ok, so there's going to be some rewriting to do but it shouldn't be too bad. Post back with any questions.

EDIT: AD beat me to it ^^^^^^^

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just use the matrix notation. I assume you have numbs added to the HORIZLINE. Say you add 1 more vector<int> called numbs2. So to add onto numbs you can say HORIZLINE[0].push_back(whatever); and to add to numbs2 you'd say HORIZLINE[1].push_back(whatever); . I think I'm interpreting your question correctly.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is it a 2D vector or is there another vector at each of the positions(like a 3D)? Perhaps a small piece of the code would be helpful.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I wish I had a direct answer for you but some poking around yielded this thread which had a couple of good links. I don't know if it's what you're looking for or if you already ran across it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Depending on the layout of the file you should be able to use fgets to get the string and then use strcmp to compare it. If this is a direct continuation from your other thread's question you should ask a moderator to close this one and merge it with the other.

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

Welcome to floating point. :) You'll find that small errors here and there can propagate very quickly. First try a much better approximation for pi and see how it changes things. It may buy you a little bit. Also, going from floats to doubles probably doesn't buy you much and just takes an extra step.

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

Scratch that I didn't uncomment the line. Hang on for a bit.

On line 63 change int to size_t so that the types match between the size() value and the index.

Also, definitely don't open your file each time through the loop move that open line up where the ostream is declared. That doesn't seem to be the issue however.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Give this a read. There can be problems with stray '\n' (newline) characters in the buffer. The code snippet there shows how to flush them out (and even offers the use of getchar as a more effective method in this case.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

myfile << data_[i+ndim_*j] << " "; should be myfile << data_[i+mdim_*j] << " "; Since you are jumping by a count of the number of rows each time you span a column. Do a quick "desk check" of it with pencil and paper to see.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm curious if it is the Event.h, why are some of the derived classes working and not others?

@OP: have you actually been able to employ the other derived classes in (working) code or was that just speculation?

I concur with Thomas, it couldn't at all hurt for us to have more of your code to test.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yea but this is for Visual Studio 2003 and I'm using 2008.

It's identical, I just checked it to make sure. Mine just says "Properties" on the project menu but I've seen it say "MyProjectName" Properties at points. Click on configuration properties on the sidebar of that window to get it to expand.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

you need {} in class train;

so it needs to be

class Train{};

No, that's a forward declaration. You don't need the braces. If you are going to use another class as an object in this class, that class must be defined first. However you don't need the full declaration you can "forward declare" it just so that the compiler knows it exists.

Also can you explain this bit here?

Arrival(int time, Train* newTrain);

This is a constructor for Arrival which takes two arguments, an integer and a pointer to an object of type Train (hence the forward declare before).

I don't know if this has anything to do with the problem at hand but when you define a constructor aside from the default one you have to explicitly define the default one. So you'd need: Arrival() {} amongst your public declarations (or you can implement something if you need a default behavior).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have a few other subclasses of Event and they aren't giving me any trouble.

How are their class declarations different from this one? I don't see anything in this one that's incorrect.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

@HBK_100

Unfortunately, you're wasting your time. Read his/her user title.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you allowed to use a vector? If so you just pass in the vector and you'll have the count and you can find the max in the bucketSort function itself.
Even if you can't use the vector (noting your use of printf might lead me to believe that you were trying to make a C program compiled under C++) you can still calculate max within your bucketSort function.
Failing all that you can probably tack your n onto the end of your array and just make sure you avoid it in the loops, but that could be confusing for you and inviting trouble.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'll give it a test drive. I kinda figured it was that banner ad from the way it looked in IE. As always thanks for checking into it Dani :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Matrices in C/C++ are laid out rowwise (versus columnwise like you are doing,used in FORTRAN and probably others, I think) first one row, then the next, etc. So expanding your first matrix would look like 1 2 3 4 5 6. There's no need for rearranging.
Here's a nice diagram.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

But dword[a] > 0 will compare the ASCII value of the character at 'a' index of dword, which will always be greater than 0, right?

Also, its error acc. to my compiler.

Yes you are correct. I wasn't saying it would be an effective loop just that it was by some means "valid." I'll have to try it out. I don't think that's the approach to be taking anyway so I wasn't going to worry about it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would just loop over your string:

for (int i = 0;i<dWord.length();i++)
{
          //figure out shift from number and the criteria I gave you
          dWord[i] +=shift;
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In for loop, you used condition "dword[a] > 0" ? What you meant by that?

While I don't know if it buys the OP anything it's as legal as saying a<10, it's still a condition that returns true or false.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A few things: <iostream.h> and <string.h> have long been standardized to <iostream> and <string>.
Also, try to avoid goto if at all humanly possible. Look into a do/while loop for a cleaner way of doing what you did there.

Rather than going through a system like you have there consider using modular arithmetic with the % operator. So for example if you character was 123 and you had a shift of 10 you would get 123+10 = 133 % 127 (the last character in the set) and you'd arrive at +5 since we are counting zero.
To do the reverse you simply subtract the character number - (magnitude of shift) % (character number). If the value is less than 0 add 127 on to it.
Double check my math on those. There may be fancier ways of doing it but these should get the job done.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well you need to put a cout << endl; within your outer loop at the end so that you get it each time you complete a row

for (outer loop over rows)
{
    for (inner loop over each star in the row)
        print the star

    cout <<endl; //now we go to the next line
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is your loop:

for (count = 0; count < input_1; count++)
{
     for (count = 0; count < input_1; count++)
        cout<< " * " <<endl;
}

Trace through your loop the way you have it, it's going
* (+newline)
* (+newline)
* (+ newline)
*
since you have an endl after each star. Your inner loop need to print the entire row of stars so keep endl out of it. Put 1 endl just outside of the inner loop so that you catch it each cycle (after a row is written) through the outer loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Since mid-afternoon the text in the C forum has been showing up centered on the page (thread listings, threads). I'm using Firefox 3.58. I just checked on IE 8 and it looks ok except that the Intel banner ad is in the wrong place. Anyway, just thought I would let someone know. Anyone else having this problem? (I remember a few weeks ago the WaltP was having some trouble in FF but it was in all the pages I think?)

And it seems to be okay now. I had given the page a shift-Reload before and nothing changed but now that I went back to it it looks fine on FF. Still probably good to be aware of it as somethings up. I prefer it when the web behaves deterministically. ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Move the endl in the for loops outside of the first one so it's only called once per row. Also, you don't verify that your input fulfills those criteria you just print it out. See this thread to get some idea of what's involved. If that's a lot, simply test whether then number is positive.

Also, please learn to use code tags:

[code]

//code goes here

[/code]
(just like HTML but with [] -- or just highlight your code and hit the

button in the toolbar).[code]
button in the toolbar).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
ofstream myfile (filename.c_str());

Gives you a C style string that the method wants (with a '\0' (null) terminus).

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

Rather than using setw why not just print the number of spaces you need:

+  (3 spaces, 1 character)
    +  (3 spaces, 1 character)
    +
  +++++ (4th line down print across no spaces)
    +
    +
    +

Adjust accordingly (it's not quite balanced but you get the idea)

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 get the following in the output file:

Average of 0.3*x^2+0.9*x+4.7, on [2,-5.4] is 5.406Average of 5*x^3+6.3*x^2+x+0.4
, on [10.7,1] is 1964.41Average of -x^1-x+2, on [0,0] is -1.#INF

I can't reproduce any of the errors that you have stated. It prompted me for a file name it did not skip over that. This is what I had in main():

ifstream in;
ofstream out;
process(in,out);

A couple of other things. Rather than doing all the file operations in the function I'm assuming your instructor wants you to perform all the opening in main and then just pass in the ifstream and ofstream objects. Otherwise there's no point in passing them in since you start fresh in the function anyway. Also, your function is supposed to return an int but it doesn't seem like you're sure of what that int should be -- is it a success or failure indicator or something completely different?

Also, I had wanted to say it's really cool that you decided to join the site as a sponsor. I'm confident that it means a lot to Dani too. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

street is not declared as an array. However, even if you were to declare it as such, you must declare the rows and columns at compile time. Some compilers may allow you to declare street on line 33 (technically after the time when row and column should have values) but this is a non-standard behavior
The alternative is to allocate the array dynamically (See: http://www.codeproject.com/KB/cpp/arrayDinamic.aspx). It just takes a few lines to do so.

EDIT: CP beat me to it ^^^^^^

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What you have won't be too difficult. If you can write a for loop to iterate through your array, just use the >> operator to read an entry from your file into each slot. It will get the next value after a space or newline. Give it a try and then post back if you're still having trouble with it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Welcome. What have you tried so far?

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

Well, you're not needing any return value back in main() nor are you returning anything in the method so really you should use void.

Try to figure out where it's crashing. Either run it through a debugger or pepper your code with couts to watch its progress.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you don't know any of the values for the parameters you're not going to be able to solve the equations. If you don't have any of the parameter, do you have values for x1,x2,x3 and y1,y2,y3? Please tell us what you have been given.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
while(!in.eof())
    {
    in>>n;
    double * coeff = new double[n+1];
    for(int i=n+1;i>=0;i--)
        cin>>coef[i];
    in>>a>>b;
while(in >> n) //don't use .eof see "http://www.daniweb.com/forums/post155265-18.html"
{
   // so now we've got n do the allocation
   //instead of cin you need to use in
   for(int i = n+1;i>=0;i--)
         in >>coeff[n];      //we get the exact number of coeff we need
   in >>a >>b;
   //do the processing 
   //output results
   delete [] coeff;
}

Then your loop is all ready for the next line, it get's the next n, allocates again, does the processing you're in business.
(otherwise reading in all of the data at the same time would give you a 2d array with varying lengths in one of the dimensions which could get messy).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's nothing to delete in your code yet. However, you haven't specified a length for your array. Coeff should be a double * so you can have a line between 28 and 29, double * coeff = new double[n+1]; (since your polynomial has n+1 terms). Then at the end you call delete [] coeff;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Since none of the equations depend on each other at all you can solve it as 3 separate quadratic equations so either with a root finder or the brute force (-b+- sqrt(b^2 - 4ac)) /2a business.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Name it whatever you'd like in the method. void HotDogStand::JustSold(int DogCounter, int numCarts, HotDogStand CartSales[],int yvaluefrommain) Now you can use it like a count (in other words you have y items). Looking back in main() it seems like that loop only goes 1 time anyway (on line 36 of Jiwe's post) so there may not be any point of passing it in anyway. My main point was you can't just say CartSales[y] in the method because y doesn't exist there.