jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can do it but it will require a lot of nested if statements. You could either have a command on each level and have the user only exit one level at a time --> e.g., login -> choose menu item 1 ->into menu 2->exit->back to first menu->exit->logged out -or- you could just call exit(0) whenever the user types in exit. The latter may become more error prone.
Is "if" statements the only thing you have covered so far? Anything with arrays or functions? Those two things might make this slightly easier.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

3. How can l add a commend after each prompt that if it is not the same as the the (getinput=="~~~") it goes back to the start?

Can you clarify what you mean by this?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I guess when you retake the course next term you'll have to ask a lot more questions and seek clarification.

Well, to reiterate no one is going to just hand you a project.

Start looking at examples of code out there on the net. Try to recreate some of the simpler ones and see how far you get. AncientDragon is 1000% correct though, it's a mighty push to learn the basics of C in an entire term let alone 3 days.

Salem commented: *agrees* +19
tux4life commented: *agrees* +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'd put it in a 2D array. That way you can iterate over the rows and pick a random die face from each to face "up". Making your swaps with 16 different arrays could turn into a nightmare. I don't have too much to add besides that. Sounds like a neat (and doable) project!

Definitely post back if you have any further questions about it and hopefully you'll get some other suggestions on this thread.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Would something like this work (if you used Visible = false in your resize method instead of Hide())?

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
        if(this.WindowState == FormWindowState.Minimized)
               this.WindowState = FormWindowState.Normal;
       this.Visible = true;          
}
j4jawaid commented: Thanks. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not commenting on anything more until you put code tags on it. I showed you how, there's no excuse.

Salem commented: You tell 'em! :) +18
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When you have an array you declare it as type arr[size]; When you access the array you put in the desired index, e.g.,

int arr[5]; // holds 5 elements
                 //but the first element of an array is arr[0]
cin >> arr[5]; //INVALID since arr[5] is the 6th element of the array
                       // no such thing

now with:
afile >> stu [i].st.uks.name [MAX1] ;

you're accessing stu so far so good, member st.uks, ok that's valid, and now you try to access the name member, but at MAX1 which is one index too far (at best you'll hit another initialized area of memory but at worst your program will crash and burn).

So your ifstream statement is trying to write the name you read in from afile, but read it into a variable that's only 1 char long (accessing name[index] only give you one char out of your array) and into a character that you don't have the "rights" to.

Enter getline. Did you read the reference at all? This is a method that will help you read into your char arrays from the file. afile.getline(stu .st.uks.name) (NO index this time) will read from your afile into name. Read the reference about delimiters and decide how to separate one line of your text file into multiple "lines" to read into your variables (hint: what separates the country of the student from his/her name).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It has a variant Substring(startindex, length) . If you're going to do it based on index of the number alone you could copy it into a new string without the commas.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't use goto. Use a loop instead. This way you can put in an exit option. When getting input like you are use a do/while loop so that you can test for whether you should exit the loop after you've gone through one cycle.

Your function names leave a bit to be desired and the abbreviated names seem to be opposite of what they should be. There's no need to skimp on characters especially for readability. It's the old 6 month rule, could you come back in 6 months and know what exactly they did?
(also why comments are a great idea)

Skip all these sleep calls. By and large the places you have them wouldn't require it anyway. Needing the Windows functions adds a tremendous amount of overhead to your application.

Your functions return an int, but you should actually return the value you got for the conversion to the main program so their return type should be double. When returning to main() use the return (your double variable here); keyword, don't call main again. Skip the "would you like to go back to main" portion of it and just have a return statement (no system("pause") in these functions either).

Your system("pause") in your main program will never see the light of day as you return 0, and you've exited your program. But skip it anyway because (and you had the right idea with the getchar) use cin.get() to have the user press a …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's two different people, that's why. Bokac piggybacked on the original thread (which he probably shouldn't have).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A few hints:
1.) int square(int side, int i); is a function prototype. It should not be placed in main()
2.) function parameters are used to convey information between different methods. what information is i bringing into the square() method?
3.) grab a pencil and paper and go through your loop step by step for say side = 3, read through the instructions and draw what the program output is. You'll find at least one of your errors quickly.
4.) Where is the zero co ming from on the display? What are some of the options for the return type of a function? Do you need to cout for everything?

tux4life commented: Good hints :) +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are your indicies of a type that have the ability to be directly compared? (like ints or strings)?

If not you must write an IComparer<your_index_object> method and pass it into the constructor of the sorted list.

Here's the MSDN for sorted list.
http://msdn.microsoft.com/en-us/library/system.collections.sortedlist.aspx

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

textBox1.Enabled = !checkBox1.Checked;
(using exclamation point)
Try it like that for the effect that you want.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When going through your loop after entering in the physician's name

for( i=0;i<n;i++)
		{
			cout<<"\nEnter physician "<<i+1 <<" name :";
			cin>>phy_name[i];

it's trying to write the entire name to phyname which is only one character. Consequently the extra characters remain in the stream, writing into the next set of variables and so on.

Using strings would be the best idea (std::string). However, sure I know it's probably your assignment to use char arrays, so look into a function like getline() (used as cin.getline(chararrayname,capacity); see this for a reference) but you'll need to cin.ignore() some characters that are left over in the stream after the getline (especially if you are still using cin >> for your ints and such).

Ancient Dragon commented: good answer :) +25
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does that mean?

It was mainly tongue-in-cheek but it seems like everytime I come to the Geek's Lounge you've come up with a huge topic, which in and of itself isn't a bad thing. It just seems like you drop ideas for the sake of instigating and then don't end up having an earnest discussion of the topic. Then it's off to something else...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need parentheses when you call a default constructor (which is what you should do on lines 57-58

dayOfTheWeek DayOne;             
    dayOfTheWeek DayTwo;

You should also declare a default constructor, that is: dayOfTheWeek() up in your class declaration (next to the other dayOfTheWeek(string) one.

For your getDay method, you're not passing in a parameter (see your declaration in the public: section). Just leave it as getDay() which in reality is the same as getDay(void).

In the printDay you shouldn't be passing in a parameter either. Your printDay method has access to the private member dayOfWeek, so you can just print that out directly. Start to think in terms of the objects you are creating (DayOne and DayTwo) as having these methods and member variables intrinsic to themselves (so DayOne is carrying around it's own dayOfWeek string and DayTwo has it's own, and they are each able to use these class methods independently of each other).
I think that's all the major errors, there might be some minor ones around...

EDIT: You need to put {} after the declaration of your default
constructor, that way you don't have to put a full definition.
And with regards to your set function, you should probably do the data entry in main and pass that value through the set rather than passing it in and then overwriting it anyway.

froggy1976 commented: thanks! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I use monoDevelop on a mac book pro

Gotcha. Well I'm using the old fashioned VC# express. Google around and see if there is some setting for wide characters that needs to be set. I would only be guessing.
I would tag your post (see further down on this page) with "mono" or "monoDevelop" as it may attract those in the audience using those systems/tools.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

hint: on this line printf("\n\tThe binary number %s has been converted to %d decimal\n\n",i ,result); the variable i is not a null terminated string.

Also, try fgets(reference here - ignore that it's a C++ site)for your input it's much cleaner (and standard).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No problem! Nice job seeing it through.

ddanbe commented: Nice guidance! +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I just meant to change a digit here and there but ok. See my edit to the above post.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try looking here

Salem commented: Works for me :) +18
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is a time when you need golf commentators at the forum:
"Well, Jim we're waiting on a post from JoaoC to see what he's got up his sleeve"
"Bob, all we can do it just wait patiently. The crowd is quieting down, he sets up to putt"

Nick Evan commented: Haha :) +12
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How about (I use a dictionary but you could use any container to keep track of the line numbers or strings):
(you can flesh out the other portions -- I can't have all the fun)

bool found = false,last = false; 
                //strdict is of type <int,string>
                while ((temp = sr.ReadLine()) != null)
                {
                    if (Regex.IsMatch(temp, regMatch))
                    {
                        if (found)
                            last = true;
                        
                        found = !found;
                     }

                    if (found ||last)
                    {
                        strdict[lineNumber] = temp;
                    }

                    if (last)
                        break;
                    
                    lineNumber++;
                }

This gets the lines starting with the first match and up to the second match (I think that's what you were trying to do...).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's also the intersect method of the region itself. It requires a rectangle but send your point in as a 1 pixel by 1 pixel rectangle. If the intersection is empty you'll know the point is not there (looks like you need to save a copy of your region first since it will clobber it with the result when you call the method). I don't think that makes any assumptions about the shape of the region.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I gotcha. I had that possibility in the back of my mind but I wasn't sure how the regions were defined. Apologies.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you use RectangleF rf = r.GetBounds(graphics); then if(rf.Contains(p)) do whatever? I'm assuming that graphics is of type Graphics and is initialized somehow.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Pop in a second variable to keep count in your new array.

int j = 0;
for (int i = 0; i < customer.Length; i++)
            {
                if (TypePerson.Manager || TypePerson.Vip)
                {
                    importantCust[j] = customer[i];
                     j++;
                }
Sivyo commented: Thanks this is the answer. So obvious, don't know why I didn't see it +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

should i not use arrays to do this?

Unless you know the exact number of records you will have (or it can be determined at runtime e.g, by the user entering a value), it is far better in most situations to use a list. Take a look at some of the information and links that the other posters have provided for you. A list will expand itself as it needs more storage (to a finite limit of course but far far larger than anything you would need). A list also has built in methods that make it highly searchable and sortable. C# arrays provide a few more bells and whistles than their C++ counterparts but they are still limited.

i cant use variables because people can enter more than one

I'm not sure what you mean by this... do you mean more than one record. You can use the Add() method of the list ad nauseum. Make a new object, add it to your list (if you're feeling adventurous you could simply add a "new" object myList.Add(new myObject(constructor parameters)); and save a step).

I hope I haven't made you more confused. It might be helpful for you to give us a brief summary of what you know so far about arrays and lists and why each would or wouldn't be appropriate for your problem (1-2 sentences not a term paper).

Geekitygeek commented: very well put :) +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was being facetious more than anything about the 0.25, I know it's important. However, with your calculations you were losing 5 days per year.

cwarn23 commented: Thanks for pointing out the error... +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Last I checked on the calendar a year had 365 days (+0.25 fudge factor)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

$year=floor($time/([B][I][U]360.25[/U][/I][/B]*24*60*60)); If you're going to be Captain Smartguy, you ought to have your numbers correct at the very least.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not 100% sure. I honestly don't have the experience with this kind of thing. That article seems to cover what to do with typedefs but in the context of a struct. People that know more about this kind of thing will probably pick up on the thread. I just didn't want you to think you had to scrap and translate everything. I wish I could be more help.

sknake commented: good advice +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes. What do you have so far? Please read http://www.daniweb.com/forums/announcement8-2.html

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 29 should be chcount[lcv]++; instead of chcount[lcv] = chcount[lcv]++; which can cause weird results.

Ive gotten it so it works after hitting enter then EOF but it counts the enter as a character.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Part of the problem is you want lcv == CHARCOUNT on line 36 -- you've traversed the entire array to the end and the character isn't there. Ignore what I said in my other edit about EOF, but make sure your user knows to hit EOF (ctrl-Z or F6) at the end of the input.

(sorry about all the edits, I had a train of thought but got derailed -- I thought I knew exactly what was wrong with it right off the bat but it needed a closer study)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry restrictment, because that is "ASCII art" he's talking about, making shapes/pictures out of ASCII characters.

ASCII is the American Standard Code for Information Interchange. Contrast it with a slightly older standard like EBCDIC (which I think still exists on some mainframes). From my understanding of it, if your system supports ASCII (see this table) lowercase a, for example, must be represented by 97 (as do all the other letter, symbols,and things (like "beep")).

UNICODE is a newer (late 80's early 90's) which encompasses a much larger set, including many of the international alphabets, but still has a subset for the original ASCII codes (entitled UTF-8).

Well, that's probably way more than you wanted to know but in a nutshell it's just the numbers used to represent characters and a standard for saying how that conversion should be laid out. This wasn't mean to be exhaustive but more to give you the links in case you wanted to know anything else.

tux4life commented: Excellent post :) +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would skip over the buffer completely.
Make name and color strings (e.g. string name; )
Create a loop and read:
myfile >> s1.name; //but see below, should be s1.name
myfile >> s1.color;
(get the int)
(get the other int)
then repeat this over and over again for all the lines of your file. So you should make an array of people actually.

Oh yeah, and qualify main() with int (e.g., int main() ).

shishio1014 commented: hes a good programmer +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is really a C program, which should be in the C forum. You wanted to stay on "AT&T Boulevard" but take a left on Ritchie Street instead of taking a right on to Stroustrup Lane.

Try dropping a getchar(); statement at the end of the program before your return statement.

Also please use code tags next time. //your code here

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Welcome. Please read the following http://www.daniweb.com/forums/announcement8-2.html
After you've looked it over and brought some code to the table, we'd be happy to help you with it.

Salem commented: Well said! +17
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Under the Edit menu, Advanced, (uncheck) View White Space
CTRL-R,CTRL-W (first one, then the other or both at the same time)

(I remembered these from a similar setting in Word -- not the same keystrokes I don't think)

Excizted commented: Thanks for helping :) +1
Ancient Dragon commented: Very helpful -- I couldn't figure it out either. +25
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://www.embedded.com/story/OEG20020429S0037 (it happens to be an embedded article but it still applies). When you are passing parameters to a function they are not guaranteed to be evaluated from left to right, right to left or any other order. I tried it on 2 different compilers (VC++ 2008 Express and gcc 3.4.2) and they gave 2 different answers so it's one of these "unspecified" kind of situations (from the article) and can't be relied upon. The best solution would be to perform the arithmetic for one step, print it out, step two, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well more than likely your program is going to be doing some event driven stuff (reacting from a button getting clicked, text changed in a textbox).
Just to test out the concept put a button from the Toolbox onto your form (or whatever your gui need is),go over to Solution Explorer and there should be a tab saying Properties on the bottom of that window (else go to View/Properties Window). With the Form1.cs [Design] tab active and the button highlighted click on the lightning bolt in the toolbar. Go to the blank cell to the right of where it says click and double click it. You'll get an event handler button1_click (object sender, EventArgs e) placed into your code for you. Put whatever code you want associated with the click of the button in there(and you can call other methods you've written in class Form1 or in other classes and even trigger other events). So for example with the main window you can use a load event to execute code on startup. You could call other methods at the end of InitializeComponent() but I think it's much more practical to use the events to take advantage of the paradigm.
Just my half nickel but I figured it might help you to get your hands dirty since this ain't your first rodeo.

ddanbe commented: Nice explanation +6
roswell67 commented: directly tackled the problem and explained everything. Loved the post. +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try something like this. The true passed to ReadKey() suppresses the output of the character to the screen.

ConsoleKeyInfo a;
            do
            {
                 a= Console.ReadKey(true);
                switch(a.Key)
                {
                    case ConsoleKey.O : Console.WriteLine("You ordered an orange");
                        break;
                    case ConsoleKey.A: Console.WriteLine("You ordered an apple");
                        break;
                       //etc.
                }
            } while(a.Key != ConsoleKey.E);

Since ConsoleKey is an enum it is acceptable input to the switch.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please show us what you have so far.
Take a look at this http://www.daniweb.com/forums/announcement8-2.html

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would add another dimension to your array, e.g.:

char answers2[5][4][2] = {{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}}};

(has all 12s but you get the idea)
or you could use an array of strings to accomplish the same thing (leave it as 2D).
You have a '10' in your array which isn't a char.

restrictment commented: Yeah, very helpful +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try going to a prompt and compiling it as g++ exercise9.4.cpp exercise9.4main.cpp -o ex94 substitute your own filenames and exe file name. Somehow I think your project in C::B is not set up correctly (I don't use it so I don't know how to remedy it). You may be trying to compile your main.cpp first and it doesn't have the other code to link in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put a cin.ignore(); before each of your getline statements (and get rid of the extra cin for songName). That will get rid of the extra \n character from when you press enter for your cin>>answer; prompt (since answer is only expecting 1 character, the \n is left in the buffer and fouls up your getline). I'm sure you put them in there for testing other options but you don't need to redeclare albumName, etc in this function. In testing this, I again put an extra PrintLibrary() call after I called UpdateRecord(); instead of passing in the ofstream directly.

MrJNV commented: Damn helpful. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out the partial keyword:http://msdn.microsoft.com/en-us/library/wa80x488.aspx I think it's exactly what you need.

ddanbe commented: Good thinking! +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why do you have an extra set of parentheses on the end of your function prototype? Get rid of those and put a semicolon at the end.

Also, you probably want to pass in ifstream by reference:
void a(ifstream & b) in your prototype, nothing extra required in the function call itself.

Thumb2 commented: Straight to the solution +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

...how? Can you copy that code and paste it here?

See my edit on the previous post.
You also have your print to screen method starting from 9 for some reason. The "junk" you are seeing when this is output is due to printing uninitialized variables, which will go away once you feed it the whole songset (or keep track of the number of structs written with a counter and send that number into your printing functions as an upper limit)

MrJNV commented: Helped a major issue +1