jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's on line 9. 0.5 is considered a double. Change line 9 to area = static_cast<float>(0.5*sum); to tell the compiler that's what you mean to do (or use a C style cast like area = (float)(0.5*sum); )

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't worry about initializing them to NULL if you're just going to turn around and initialize them with new one step later, just do it all in one step like you did.

To set them to zero, do what you did within your function. If they were static you could do it all at once, like int a[5] = {0}; but they are not.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That should be right. Post your current code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The first is a preprocessor directive, before the compiler compiles your code, it will go through and replace sum with 1. The second declares a variable in memory to hold that quantity. I'm sure it can be argued as to which is best, but the "const int" is probably more common in C++ (when it comes to numeric constants).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On line 8 and 13, you are creating #size2 sub arrays each of size2. When you are passing it into the function, the compiler is interpreting it as a int ** (i.e., a 2D array). Don't do the loop, just initialize a and b as new int[size2] .

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Within main, call getSize() and after that use the 2 values to establish the dynamic arrays in main(). Pass the arrays and the sizes into createArrays, and initialize them to zero there. Then pass the arrays and sizes into fillArrays.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster


123456789012345678901234567890
Row 1 ***###***###*########*****####
Row 2 ####****#####***************##
Row 3 **######*************#####**##
Row 4 **######**************##******
Row 5 ********#####********#########
Row 6 ###############*********######
Row 7 #######************###########
Row 8 ***************##****#########
Row 9 ##########*********#####******
Row 10 #****************#############
Row 11 #************#######********##
Row 12 #################*********###*
Row 13 ###************########**#####
Row 14 ##############################
Row 15 ##############################

okay so i wrote the code so far, its working except i have a few issues i have come across:

1. When select option 2 to purchase a ticket, it promps me for the row and seat number, but after that it asks "Would you like to look at another seat?(1 = YES / 2 = NO)" if i pick either option the program freaks out.

Doesn't happen if the user enters in a number, but if you hit a letter, yes, the stream goes bad and it loops. Either check if the stream fails using cin.fail() and loop back if the input is improper, or take the input in as a string and make sure it contains the integer, convert your string to integer, and carry on.

2. My second issue so far is that the seating chart is not aligned when asked to display (option 3)

This is going to take some finagling. I would stack your seat numbers on top of each other if they are 2 digits, like:
1 1
1 2
for 11 and 12, etc. Since some of your row numbers are more than 1 digit, you'll have to bump the first rows over a set number of spaces. Use an if condition in your printing loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your problem is in line 34. Say there are 10 students, so on the line before you set aside an array of 10 (which has indexes from 0 to 9).
So next you are trying to create an array at student[10].test, which doesn't exist.

You must have a loop going from 0 to numStudents and initialize all of the test arrays in a row.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

num1 only exists within the scope of main, you must pass it into your function to use it.

I have been reading your posts and I think that you are missing some fundamental ideas. If you have a textbook, go back and reread the appropriate sections, as your misperceptions are going to be harmful to your coding.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

"lastfile" and "lastFile" are two different identifiers

chode1 commented: life saver!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See if something like this http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/ will help you at all. You can use the fact that it doesn't convert if there is no valid number there to your advantage (and just account for the negative values post hoc)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Caveat: I've been trying to get a sample together and have been having some problems with circular references. It's fairly trivial in C# since there are no headers.

Take a look at http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/097d7025-7c67-444d-909a-a91d05eb298d/ which is one of the clearest explanations I've seen as to how to do this. Also note they give some alternatives too!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Modify the constructor of form2 to take a form1 object. Assign that to a private form object in your form2. Operate on it like you would any other object.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use a loop check to see if a given value in the array matches the data you are looking for (or meets a certain criterion). Then set that value to zero or something appropriate to that particular array (so if it's a string array, set it to space or something.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
[100 | 95 | 85 | 50 | 91]  //read into this int array (show here illustratively)

//use a function to translate (your if/else construct goes here)

['A' | 'A' | 'B' | 'F' | 'A']  //your new array

A char array is just an array of characters, so char grades[MAXSIZE];

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Tou need to compare apples with apples, so compare InUserName to ID[count].username

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It shouldn't have compiled, you declare sizeOfArray after you try to use it. Take that value in before you instantiate a string array.

See what I wrote in your other post too, you have a bunch of uninitialized pointers declared at the top of your code which are going to choke your code if you try to use them.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Review in your text the distinction between char * and string * -- I think you are very confused. Also, you are reading into a bunch of uninitialized pointers. Yikes.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See your other post. It indicates a pure virtual function, which automatically designates your class as abstract.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

virtual void clear()=0; makes your class abstract (as it is a pure virtual function). You must inherit from your class to use it.

BTW, you don't have to specify "public" as an access specifier in a struct, line 9, as structs have a default public access to all members (and classes have a default private).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please post the current code with which you are working.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Edit:
NVM your problem isn't the c_str(), userInput is already char.

strcpy (cstr, userInput);

userInput is a string * which means you have to dereference it using the -> operator, so userInput->c_str() @OP You still will need to include <string> if you are using std::string in your code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

2 things to note:
There's a relationship between the number being read in and the desired index of the string vector.

When you are erasing on line 43, you are changing the vector's size, which affects your counter.

I'm sure you've had iterators in class too...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

and the worst is that they gave us this task before explaining the functions

I'm sure there are on the order of 10^23 pages online about functions and you probably have a textbook.

This is my interpretation:

string dec2bin(int decimal); //prototype

int main()
{

  //input a number "num" here
  //pass num to dec2bin
  //print out answer
}

string dec2bin(int decimal)
{
  //do your input calculations and your string manipulation
  //return the string to main

}
kvprajapati commented: I did't knew it :) +11
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In the second listing, get rid of line 7 and wrap the code from 10 to 81 in

namespace SALES
{


}

You need to specify that all of that is in the same namespace as your header file declarations.

There's a bug with one of the array elements, but you should be able to find it now that you can compile and run it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I tried playing around with their demos and couldn't reproduce it. I couldn't test my theory that it happened when the dialog popped up in conjunction with me scrolling on the page.

I shouldn't have the ads, I've turned them off.

Okay. Well, I'll solve this one for now, but if it acts up again I'll reinvestigate it further.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint: what would be a good name for a method that returns the size of an item?
(there are two options for string actually). Put Google to work for you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That may not be the only issue, but it's a start.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Pass in numusers to ReadAllUsers by reference. Change lines 14 and 33 and add an & between int and numusers.

The way you have it now, numusers is uninitialized in main, so you send garbage into ReadAllUsers, which only changes a copy of it to a value, but the one in main() is left unchanged.

It never hurts to initialize a variable (to zero or otherwise) when it's declared and is necessary if you are going to use it for a counter/index variable etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Never done it but there's plenty of documentation out there: http://stackoverflow.com/questions/145270/calling-c-c-from-python seems to be loaded with information.

Try searching the Python forum here too, but don't double post your thread, ask for it to be moved (click 'Flag Bad Post') if you think your question is better suited over on that side.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, you can turn that option off.

It hasn't happened for the last few, but I think I was actively scrolling when the ones that caused the freezing came in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, what have you come up with so far? Please show some effort.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

<Sorry, misunderstood the question.>

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No one is going to give you the source code, that's unreasonable to ask as it is your project.

Break this down into smaller tasks and plan out what you need to do for each one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See if http://www.cs.bu.edu/teaching/c/queue/ helps you (it's not a link to a page, but it's a link to a directory tree that has 4 webpages of information in it). It's about C not C++ but the concepts are the most important thing. You should verify with your instructor the details of your array-based implementation.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not going to give you the answer, I want you to figure it out on your own. Is there a section on big-O notation in your text? In other words, is the efficiency of your algorithm in either of those cases dependent on the number of items in the queue?

Draw a diagram with your model queue on top and the array (or list) representing it underneath, what has to happen after you remove the first item?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 60,122,123 (etc) never use gets. You can overrun your buffer and crash your program. The gotos make everything a little sloppy.

Can you elaborate more on those issues? What about it doesn't work? Is it the file reading or the password matching? You can shed some light on these issues by running it through a debugger or by cout'ing your variables along the way.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to be specific about what the issues are. As the great (moderator) WaltP will tell you, "we're not mind readers."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nice find!

Yeah, she 60-something by now

Like a fine wine... lol ;) j/k

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You probably don't need system if it's a GUI application, as clicking the button to display hello world shouldn't close the window unless you explicitly tell it to.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Actually, you do need a string array on line 3 of your original code. This really should be a pointer to string which you initialize using new in the registerCourses method (or if you knew the number, in the constructor for the class).

string * namecourses; //in the private members and 

namecourses = new string[numberOfCourses];

If you're not stuck with this design, it might make more sense to have classes labeled Student and Schedule, where a Schedule object has an array of courses and a number of courses, and each Student object has a schedule.

Thanks for clarifying the j. I'm not sure why you needed an intermediate variable when you could use numCourse. That array on line 11 should be dynamic also (as fixed length arrays with size not known at compile time are non-standard).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where does j come from on line 66?

In terms of what you are trying to do, at which step is it failing?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you have support to MFC library then you can use CImage class. Its very easy to saving image as jpeg using CImage. Just pass handle to bitmap to CImage or load it from hard drive. Call Save function and specify jpeg as saving type.

True. There are also options available in .NET if you want to go on that adventure (since if you use the express editions, they don't have MFC)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nope. if (anything = 4) is always true (the only false value would be for 0). Reread your section on comparison operators to assure yourself that == is what is needed there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

At first I thought it was a trick question (because otherwise those variables would go unmodified), but there must be a provision about passing those last two variables as references. I think you're right on the money, Vernon.

The question should ask for a diagram of the queue at the different points.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Talk yourself through what steps you have to go through to work the queue (enqueuing and dequeuing). Think about the elements of the array. What steps have to happen after you remove the first element if the queue is built on an array model?

Reread your text's section on big O notation to get the right terminology.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm assuming the parameter passed into the dequeue method is a reference one which will assign the value being dequeued into that variable (which you didn't include in the specification)? Remember to dequeue is to remove the first item in the queue. Reread what your methods do to double check.

Also, your output statement has 3 variables in the cout statement, you know you'll have to have 3 numbers.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Trace the code through with particular attention to changes on the original variables.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Dammit, my secret is out. I guess I'll have to go back to solving and unsolving my threads. :P

Ardav, you've been at Chrome much longer than I have, I guess you haven't run into this?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, you should put your CGame in main(). Make sure that if you need to reinitialize anything in between runs that you create a method to do so.

win_numb is not initialized (mine happens to say 2 each time). Such a large negative number should raise a red flag that something is not initialized. Note that lines 48 and 49 are useless in your prior listing, and you don't actually assign it anywhere.