WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I actually made a mistake, I meant to say system("cls"), this is for windows as i assumed he is using that, system("clear") on the other hand is for Linux and it always works.

And you've just explained non-portable perfectly. It won't work on all systems without modifying the code, therefore it's not portable.

And I'm not sure what you mean by it will delete all the files.

The read carefully what I wrote:

And if you have an O/S that has defined clear to be delete all files, you've just destroyed a lot of work.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

is this correct? because when I put my choice in, like for example I entered choice 1, it will just output the information that I putted in the case infinitely.

Then no it's not correct.

All your answers are contained in the responses you've been given. You just have to read *all* the posts.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Don't post 681 lines of code when all you're interested in is 70 lines. Makes the problem harder to find.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How do you mean not portable?

It will not work on most operating systems. Linux/Unix for one. how do you know it will work on his O/S? He didn't tell you what he's using.

And if you have an O/S that has defined clear to be delete all files, you've just destroyed a lot of work.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You can also use

system("clear")

to avoid flooding the screen and to start afresh every time you loop

Bad idea. It's not portable. It calls the O/S unnecessarily.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

2 comments:
1) while (true) is a terrible solution as you have no way to exit.

2) This is a perfect project to start learning how to read files. Each name and his information can go into a text file and you can
a) read the data from the file
b) populate a string array of names to output in a loop for the menu
c) populate a string array of information that can be output for the chosen name.

That way you can write the code generically, and the file is all that needs to change when you want to update information. As it is, the code is so larger it's cumbersome, and if you need to make a change to some data, you must recompile the whole thing.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How about choice != 0 ? Why a number like -999?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Tell you what. You explain as best you can what each line does, and we can help you correct your assumptions.

The biggest problem with this code is the structure.
-- No whitespace to make things easier to read.
-- Lines that do too much and should be broken into multiple lines ( for statements)

Add some formatting and comment each line then repost the code.
And don't parrot the line in your comment, for example: a = 3 // put 3 in variable a Why is a 3 being put in a?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No it's not good. Doing his homework for him is NOT good. It's called cheating, something we try to avoid on these forums.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your calculator seems to be extremely complex for the task as stated.

if minutes > 0 then hours++    ; If "part thereof", add 1 to hours
subtract minhours from hours   ; calculate hours over minimum
charge = mincharge + (hours * hourlycharge)
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Note:Toggle plain text and copy it somewhere else If it's too hard to read due to indention.

Note2: Then don't post poorly indented code. Use 4 SPACEs instead of TABs and indent correctly.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well, there you go. You tried something and it worked! Congrats.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You obviously ignored every reference to CODE tags all over the place. Even the one that smacks you in the face when you type in your messages!

I also see no attempt at all to test if a number is palindromic. Since prime and palindrome have nothing to do with each other, you have not even made an attempt. Please reread the Member Rules.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You threw out the correct answer already. It's getline() . You read the line and parse the values from it.

1) read the line (say grab val1 var2 freak3
2) retrieve the first value, the command (grab)
3) remove the first value leaving the parameters (val1 var2 freak3)
4) execute the proper command section passing to it the parameter string

In the command processor
1) Parse out the parameters
2) check them for legality
3) execute the command based on the parameters

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

something like this:

How'd you come up with that (unformatted) idea?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Resurrection from Oct 20th, 2009

Check the damm dates!!!!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You will need either files or a database (such as MySQL).

Which are files :icon_rolleyes:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

A common way to end the loop is with end-of-file:

Or by choosing an exit character and not looping forever.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I found it. It was something I did....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

fflush() on any input stream, like stdin, is deprecated,

As far as I know, flushing an input stream was never reprecated (or whatever :icon_mrgreen:), it was never legal -- standards-wise. If it was, why would they remove it? And when?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you want two values, you will need to use two variables in the scanf.

scanf("%8s %8s", &strFirstName, &strLastName);

...or use gets()

Never NEVER **NEVER** recommend gets() !!! Didn't you read the previous post? It's dangerous!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Wrong solution!!!! Do not use fflush(stdin); . Here's why.

And when asking a question, "... these solutions give me an error" is not an appropriate message to give us. There are hundreds of errors -- be specific, both in the exact error message, and the line the error is on.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Im having some problems identifying where my error is. I've read through the post on this topic and applied the responses to my code but it's still giving me a warning. I am trying to use an array to compute the average of 10 numbers.

double sum = sum + sumAverage[k];
		double average = sum/10;

What's the 1st value of sum when you do this? What value are you adding sumaverage[k] to?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Dani, are you playing around with the links for New Reply?

When I middle-click on a thread title, the link opens in a TAB as it should.
But the new-reply icons don't all of a sudden.

I can't tell if it's you playing around or me because I screwed something up...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The only question you asked is "can someone help?"

Maybe you need to ask different questions...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yeah, so? Try asking a question and describing a difficulty.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Give it a try and post your attempt (with more details) and we can help.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You're trying to shove a first and a last name, into the same variable, name[]. That won't work.

You can fix it easily a few different ways:
[snip]

char name[30]; //30 is a little small for a two name size, try 50 or 60

//fgets() is safer and a more robust input function. It will not overflow.
fgets(name, sizeof(name), stdin); //get both names as one input

name[strlen(name)]='\0'; //overwrite the newline char that fgets() adds to the name

Gee, just as I said in yout other thread! This one is closed.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The second thing is you need to give us a hint as to what's wrong. We aren't psychic. That's another website.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

scanf() cannot read two words easily. And it's only slightly less dangerous than gets() .

Look up fgets() . You will have to check the last character for \n and remove it, but it's safer and easily reads the entire line.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You probably have to parse the line in stages. When you get to the times, keep parsing until the format changes. Looks like times format is char char time time , so when the char char isn't there anymore, switch to the next format.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And isnt there any other way to clear screen other than involving system in it. Cause i would like my program to be as independent as possible.

Output '\n' 25 to 50 times. Depending on how many lines in your console.

Should i make function for exiting rather than typing it in all the time (Hardcoding is the expression i think ?)

No. Just remove the lines

cout<<"Press 1 to exit\n";
    cin>>exit;

from your switch and put them once at the bottom of the loop.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why did you remove all the while keywords in the second post?

Back to your 1st post:

I have some menu problems. So this is my first time, and I need someone to please solve the problem for me.

We don't solve things for you. We help you solve them yourself.

I need someone to please solve the problem for me.
Could someone help me. Get rid of this problem. Please someone help me.
== code ==
Could someone help me. Get rid of this problem.

4 times is begging. And if you think about it, isn't posting "HELP" on a help board redundant?


Why did you copy your program into the default case of the first switch? Just let the default go without changing gameOn -- two lines. And what's with that last while() loop that does nothing?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi, everyone!
I'm kind of in a hurry. I need to know for tomorrow how can I open a file and get the file name.

This was posted on March 6th, 2008!!!!!

Stop resurrecting this zombie for no reason! Better yet, go ahead and try! Mwahahaaaaa!!! :icon_twisted:

Card commented: Thankyou +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Or to ask a more appropriate question, "Do you have any links to reputable sites that review hosting companies?"

.kaine commented: Good Reply. +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The reason you continuously loop when you enter bad input is because you're trying to accept a number, but are receiving a char, and your input buffer is overflowing.

It's not because of an input buffer overflow. When you try to read a non-digit into an integer, the read fails. The input buffer remains the same. Next time you try to read, since that character is still there, the input fails again. And again. And ... you get the idea.

1) Test your read to see if it was successful. Don't ask How? Look it up. It's part of cin error checking.
2) If it fails, clear the input buffer as Duki's link suggests. Be sure to process the error in your code. Don't just go on your merry way and execute the code as if nothing happened.

Also, I would recommend using a switch rather than multiple IFs.

So would I, but only if you've learned them.

Duki commented: Thanks for the correction. :) +10
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What does

while (c != sk.sz)
{
	newbuff[c] = strtol(&buff[c], NULL, 16);
	printf("%lx\n", newbuff[c]);
	c=c+3;
}

display?

Until you fix your read process into something like this instead of that convoluted mess, I'm done, too. Unless you can give me a good reason for code like that.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So your professor wants you to have someone write file search software for you? You don't need to do anything but ask, correct?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi Everyone :)

I know you don't like homework help..but I have tried to answer it and got a resit and now I have no idea!!

Considering over 94% of all threads are asking for homework help, I don't understand how you got this idea. As long as you show that you are working on the task in question, we have no problem helping.

What we don't like is people dropping homework on us and asking us to do it for them.

Can someone please please help me to figure out which ones are correct???
I'm not sure but I think that it would be B,C,D and E but I'm not sure about E it seems like a trick question and C well does that not depend on how the information is backed up or copied?

Which of the following statements are correct when considering backing up and saving your data?
a) you dont need to save regulary as auto save will automatically save all documents in the event of power loss

Think carefully about this one. Why do you think it's incorrect?

b) backed up data should ideally be stored in a different location from your computer or network

Yes, this is true.

c) backed up files must be restored to the dish before use

Duh!

d) It is important to save your work regularly as data saved in RAM will be lost in the event of power failure

Sure will, therefore …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You don't have a loop that runs the fight 5 times. All you have is a loop that tosses the coin 5 time. Think carefully about your loop, braces, and indentation.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you need help you need to explain what you need help with we are not mind readers please explain in detail what you are trying to do what the problem is and where in the code the problem occurs the more detail the better also you need to use code tags your code is very hard to follow without them ill add them this time and of course dont post twice you are allowed to edit your post for 30 minutes oh and one more thing in english we have things called sentences please use them it really helps communicating your information to others i think this post shows you why

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
mylist = insert(mylist, struct Artist_type_node *artists);

Did you try

mylist = insert(mylist, *artists);

:icon_question:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Thank you in advance and i am hoping for your positive response.

Do you actually type this into each and every post? Or do you cut and paste it from somewhere?

Is it really a necessary phrase in each and every question? To be honest, it's been annoying for about a year...

Just sayin'.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Isn't this kind of what our IRC is about?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It also doesn't work if you input
12 2.5
An infinite loop is not an appropriate answer either.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So what you're saying is you defined d as a global variable of some indeterminate type, probably never loaded it with data, and expect proper values to be set into newrent fields using

newrent->Due_Date[0]=d.tm_mday;
newrent->Due_Date[1]=d.tm_mon;
newrent->Due_Date[2]=d.tm_year;
the=mktime(&d);

It that correct?

I say 'indeterminate' and 'probably' because you still leave out important details and won't completely answer questions. I dislike pulling information out of people like a dentist.

Plus you still use fflush(stdin) and changing gets() to gets_s() is a bandaid rather than a solution.

I think I'll let others help.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can't remember 'BIDMAS' if at all i know it. All i know is 'BODMAS' [and the others]

Never hear of any of them. The only acronyms I remember is "Every Good Boy Does Fine" and "FACE". They are very mathematical, too.

By the way, it's math, not maths.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sorry, I misrememberd what you said about the file.

We need to use the same basic terminology. Everyone seems to be getting confused with ambiguous information being tossed around.
1) Do not mention HEX unless you are talking about the characters '0' thru 'F'. HEX is not binary. Actually, from here on out, don't mention HEX again. I think you're confusing the issue and/or we are being confused by the term.
2) Use the terms BINARY and CHAR/CHARACTER for the values being read or sent or converted or whatever.
3) ff/FF is ambiguous, causing confusion. Use "BINARY FF" and "the chars FF" to avoid ambiguity and confusion.

So, updating my algo:

/* Open Packet File and Read it into buff */
    fp = fopen(pfile, "r");
    byresRead= fread(buff, sizeof(buff), 1, fp);
    fclose(fp);
    convert the characters in buff to binary.
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Try explaining what is wrong -- in detail.

You said to insert a counter when I enter a variable. I did that and it doesn't work. All I need to do is detect how many operators the user imputed.

And that's explaining the problem in detail? I think the first thing you need to understand is what detail means.

Your code will not enter the inner for() loop because you have c = 0 right before it and your condition is when c > 0 .

So how would you write it?

You're kidding, aren't you?

Sit down with your instructor and tell him you are having problems understanding why the code STFU referenced is wrong. He's the one you need to take these little problems to. We are a help forum, not a teaching forum and you need to be taught some very very basic concepts. Your instructor is the best one to do that.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

no its created as a separate linked list node, atleast that's how i understand it, i do not know if its right.. because the assignment says create a CD_type_node and create Artist_type node with a pointer to CD_type_node. i dont know if its a struct within a struct because that didnt work as well

A struct within a struct is not a pointer to a struct. See my emphasis in your post...

You need a field, like next, that points to a CD Node. The address of the proper CD Node goes into this pointer in the Artist Node.