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

Look at kbhit() . With that, getch() , and a timer you can do what you need.

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

How would one properly format the block of code with only one cout? I think it has something to do with the semicolons? Any help here?

By using CODE Tags :icon_twisted:

Since semi's end a statement, don't use them:

cout <<"hello"
     <<"how ya doin?"
     <<"goodbye.";
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What do you think we are? Coding monkeys?

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

In other words, add the line using namespace std; after your header.

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

It says the error is in main on line 61. Might be a good idea to show us that line.

Also string filename = Work.Title += ".txt"; should be string filename = Work.Title + ".txt"; I believe. I doubt you want to change Work.Title

WildBamaBoy commented: Good eye! +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Shouldn't the input be more along the lines of:

sum = 0
+ 12
sum = 12
- 2
sum = 10
+ 5
sum = 15

It doesn't make sense to me to have a full equation added to the sum.

Intrade commented: I was thinking that too, but he specified different (and misunderstood) requirements XD +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You're writing C which simulates a string with a character array. You can't use = to assign arrays. Look up string.h functions...

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

Here's an example of what the page looks for blud, our sysadmin: http://www.daniweb.com/certificates/stats.php?u=6790

He has a respectable 546 posts under his belt and has solved 18 threads to rank #420 for solving threads. But it might be encouragement for him to see that he only needs to solve two more threads in order to jump up to rank #389.

Except solved threads are 'controlled' by the OP, not one who answers a query. Unless you're suggesting blud find an unsolved thread and click it to solved himself :icon_twisted:

As far as newbies are concerned, the ranking statistic makes the system a little more comprenehsible. For example, a newbie might see that a member has 1,000 reputation points, but has no idea whether that is considered a lot or a little in our system. Being able to see where they actually rank (i.e. top 10 or top 10,000) makes the number all that more meaningful.

Even better, if 3 members attempted to help him, noticing that 1 is in the top 100 and the other two are 843 and 1224, maybe the first member has better creds and might have better suggestions. Not always, but generally :icon_wink:

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

Consider:

Assume that the first integer read specifies the number of values remaining to be entered and that the first number is not one of the integers to compare.

What is the purpose of the first number to be read? How would you use it?
What is the purpose of the 6 in your while statement?

Write a program that finds both the largest and smallest of several integers.

How would you do this on paper?


To chief427:
What grade to you expect to get for your code? What grade should lou38 get using your code? Please do not give working programs to students. We help people solve their problems so they learn, not write the code for them so they can cheat.

csurfer commented: Daniweb described in simplest words :) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Neither do we since "an error" is a useless explanation of the problem and there is no formatting at all making the program hard to follow.

See:
this, this, and this

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

srand() should be called once and only once at the beginning of your program. Move it into main()

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

Considering Nathan showed you how, I suppose no one deemed it necessary to respond...

NathanOliver commented: thanks +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Read this series on scanf(). It should answer your questions.

N1GHTS commented: I admire your simple yet effective method of solving problems. +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No, it's because of this

tux4life commented: Yes. +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Isn't it exactly the same for this forum as all other forums? If so, how could you post here? If not, what's different?

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

Of course you need help. Isn't that obvious?

But you need to give a very specific set of guidelines about exactly what you need. What "algorithms"?

Based on your almost description above, check each character input and create variables for num1 , num2 , and operation . Then test the operation and perform it on the two numbers.

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


(STDIO HEADER)
scanf( const char * format, ... )

string mystring;
scanf("%s", mystring);

Not a valid solution -- unless you want the ability to crash at will. See this. And since when does scanf() work on C++ Strings?

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

Dani told us that it's all the way down there on purpose so that new posters first read the topic titles while they're scrolling down.

Lame reasoning. Why would I read post titles when all I want to do is post a new thread? That's like reading the License Agreement before clicking "I accept the Agreement". It's hardly ever going to happen.

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

In f2c(), 5/9 = 0. In c2f(), 9/5 = 1. Remember the limits of integer math...

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

No I didn't, and I don't need to. Look at my point#3 and your code. Figure out what you are trying to do and what you did that didn't work properly. It's all right there in 5 lines of code. I already gave you a HUGE hint.

jonsca commented: WaltP IS a compiler ! +4
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My guess is Dev C++, since it's no longer an active project :icon_wink:

Nick Evan commented: :D +12
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Poat CODE not links.

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

Only call srand() once at the beginning of the code.

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

Dani, please make it so that quotes are hidden by default...

NOOOOOOOOOOOOOOO! Oh Please NO!

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

In your opinion, when creating a nested loop is it best to use the call function and if so is using a pointer the route to go when creating the function?

That's like asking when ordering a hamburger is it better to drive a Mustang?

The things in your question don't have a direct relationship.

jonsca commented: Sometimes that makes a difference. It depnds on how high-end the place is +4
jephthah commented: yeah, i lol'd +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You did. tkud tkud'd up... :icon_mrgreen:

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

Add cin.get() just before the return statement.

A simple search would have found this solution in seconds.

Ancient Dragon commented: Absolutely right. +28
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First lets establish the definition of the word respect:

Sure, as it pertains to the site:

Read the Site Rules
Email addresses must not be posted
Snippets of Code (sorry) are not help requests
Posts should not be just an assignment description
Excess code needs to be removed for brevity and understanding
Code Tags are necessary
Tell us what's wrong in detail, don't make us guess

I fully understand some users frustrations with lazy students who would like the community to do their homework assignments for them, however, even in this situation one can still be polite and helpful to that lazy user. All that is needed is a deep breath of patience and a simple reply of “ please do not post homework assignments for others to do for you :) thank you.”

Tried that once. I passed out from hyperventilation, since 3 out of 5 posts I saw were "gimme codz plz" requests. And we get hundreds of posts a day.

One other response may go like this, “you should just crawl into a hole and die you moron.” I fail to see how this is helpful.

I have been here for two years and never seen something like this. Sounds like hyperbole. If you do see posts like this, report them, again simple.

Then you haven't been active in some forums. There are a couple people that are a-hole enough to say this -- and they do it often.

jonsca commented: Dang WaltP you are just too mulitfaceted :) +0
BestJewSinceJC commented: Your breakdown of respect = genius! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@Everyone
This is normally how new changes are rolled out on Daniweb. The new features which need to be introduced are made live, feedback is collected from regulars, changes are made to the site, rinse and repeat. I'm pretty sure that with the help of suggestions given by the regulars along with Dani working on them, things would be the way everyone likes it in a couple of weeks.

And that's the problem. Rather than keeping the site viable, it's an all or nothing. It's the Microsoft version of beta testing -- roll it out and let the users test it.

A core of people here should have beat on it for a couple weeks before rolling out to the general population. Then 70% of the problems and irritations would be gone. Like missing features (post number, navigation, post indicators), positional faux pax's (Start New Thread at bottom), Auto-expands that cover required links, and font sizes and colors. These should not be tested by the general members.

The new changes are a bit irritating but saying things like "this new design sucks" etc. instead of giving suggestions and waiting patiently for them to be resolved isn't fair IMO.

Completely agree. But to be fair, most that say it sucks are explaining why.

Nick Evan commented: Testing? What's that? ;) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Another usability "enhancements" found:

I open multiple threads in TABs all the time. In order to get to the first unread post, we now have to click a link after opening the thread to get there. But, when I close a thread I'm done with using the TAB exit, the next TAB is displayed. In order to click the "First Unread" link, I must drag my mouse through the auto-expanding forum bar which then obscures the link. Now I have to move the mouse off target to get the menu off screen then reverse direction to get to the link.

This doesn't sound like much, but I'd like to see you spend some time (an hour) opening up multiple tabs, and clicking that link. When you've done it 30 times you get very annoyed. After 50+ -- guess what!

Some functionality is really cool. But when that coolness interferes with day-to-day operation, it's uncool.

Aia commented: Less is more, sometimes. +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hey now we look just like all the other Forums. Now I have to learn to navigate all over again. Let me dig out my GPS,flashlight & c-rats in case I get lost.

If it's just like all the other forums, why do you have to learn to navigate all over again? It's just like all the other forums. :icon_confused:

:icon_wink:

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

Don't and I mean don't ever use

gets(myString);

Read Please
BUGS
Never use gets(). Because it is impossible to tell without knowing the
data in advance how many characters gets() will read, and because
gets() will continue to store characters past the end of the buffer, it
is extremely dangerous to use. It has been used to break computer
security. Use fgets() instead.

I will add to that "Never use scanf("%s",...) and scanf("%c",...) ". See this series for an explanation why.

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

A couple more things:

The post number is missing. That was an important piece of information that takes up little real estate.

The multi-post reply button was very helpful. Please bring it back.

Convert the post icons to a square of icons (below). When more than one icon is appropriate (new, i posted, etc) simply displaying one is not helpful.


Please reconsider the click-for-quote decision. It makes quotes mostly useless with way too much work to view, since we have to click on almost every single quote to understand posts.

You keep trying to convince us space differences are an illusion. Being a magician, I understand illusion very well. If we think so, it is. Stop trying to tell us we're wrong. Consider instead whether the illusion can be corrected.

diafol commented: Agree too +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It is running very well on my side......
go through your header files folder....some files may be missing

the program and logic both are very correct...!!

Wrong, they are NOT correct. Please see the OP's question:
"in Linux using g++ compiler ... getch and _getch is not working."
What part of this did you not understand?

Ershad, if you really want ANSI Standard as your title states, you can't. There is no way to input as you desire in Standard C.

tux4life commented: I too was thinking that there's no standard way to do it, I just didn't dare to post it :$ +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I very much like the new static bottom-toolbar. I was just about to start complaining about the (again) disappearance of MFF Thanks!

Although I liked the MFF on the side bar, I think the bottom bar may work as well.

I'm sorry to be blunt, but the monochromatic color scheme, the hard contrast, the incredible overuse of whitespace.... it's horrible. While it may be an illusion that posts appear to have more white space around them now, when placed side by side with the old design, you can fit nearly two of the new posts into the same space as one of the old posts. There is a SIGNIFICANT amount of less scrolling on forum thread pages. This is mostly due to the user information being moved off to the side instead of in between posts. The main initiatve behind this was that I wanted the content to flow easier, instead of having to read a discussion "piecemeal" constantly having to jump over extraneous information when reading a long discussion.

Love the 'user info' in the side bar. Helps with scrolling as you say. But why do we need a huge title at the top of each post? Big title at the top of page, little title (just a reminder) between posts would be enough.

Now, the discussion flows much nicer, and all of the extra stuff is off to the side where it doesn't get in the way of the actual content.

Agree...

I personally …

iamthwee commented: Totally right about the quote situation. No mouseovers or clicks! +0
jephthah commented: thanks for demonstrating the rollover quote box "feature" +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Set up a 52 int array called deck. Load each value with it's index: for (i=0; i<52; i++) deck[i]=i; Now do what iamthwee suggested. This becomes your shuffled deck.

Each entry in deck can be converted into a number/suit pair with / and %. Then use your suitname and numbername arrays for output.

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

i have a piece of an unfinished program.
try to run it...

No. If you post readable code, we can follow it. Please format your code cleanly and consistently. See this.

if you go straight to option 3 and input values, how do i output these values in option 4 ?
i tried outputting my declared variables
it wont work ? why is this ?

By not declaring them only during option 3. Once option 3 is done, the variables are destroyed. Define them at the beginning of main() .

i apologize the code is so long

Then just post the relevant section of code. Then, no need to be sorry, and we don't have to search so much. :icon_wink:

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

Just found this recipe, thought I'd share it:
http://www.cgl.uwaterloo.ca/~csk/water.html

Nick Evan commented: :) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I said:

It's your job to tell us [what's wrong] so we know what to look for.

Not just post 245 lines of code and hope we can figure it out...

Salem commented: LOL - it made my eyes bleed +20
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

guys i have a problem...this function doesn't work for me...look i want this function to check in the 2 arrays pin,pin2 for previous numbers already stored in these arrays but it doesn't work...

Not a clue. Since I can't I run the code nor can I see your screen, I don't have any idea what it's doing wrong. It's your job to tell us so we know what to look for.

also when i find 2 numbers already stores(same pair of numbers) then i want even if it changes the numbers then to recheck over and over until the pair of numbers is new...any ideas???

Put it in a loop. If the 2 numbers are unique, exit the loop.

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

Who wrote this piece of dreck? It's utterly disgusting. Try to find code from a different source to learn from.

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

Yes. See
this

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

It's because x is a pointer, not data. It needs to point to data. Without the new (or &a as suggested) there is no data and the pointer is pointing into the Twilight Zone. And you can't load data into the TZ.

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

You need to think about what you're doing, not just toss anything together and pray.

for (n = 0; n < 7; n++){
               inFile >> currentDays; 
               }

Why are you reading 7 separate values into one single integer?

also, format your code. We can't tell if you have separate loops or nested loops. the code is very hard to follow.

And if you have errors, post them. Exactly as they are displayed to you. I know here's at least one in the code you posted and it's because you weren't careful about the last change you made.

Salem commented: Nice +20
VernonDozier commented: They should pin your formatting thread to the top of the C++ section. +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

fflush(stdin) -- See this
getch() -- See this
while (!feof(F1)) -- See this

BestJewSinceJC commented: Good help to the OP +5
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

> Only recently, DOH became a word in the dictionary.
If you can cite any dictionary supporting that, please do.

http://www.oed.com/newsletters/2001-06/doh.html
Definitive, I think.

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

01000100 01100001 01101110 01101001
01110111 01100101 01100010
01010010 01101111 01100011 01101011 01110011

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

No. Copy the answer code to tmpAns. Then test for black in a loop with:

If guess(i) == tmpAns(i)
    black = black + 1
    tmpAns(i) = -1      // answer code is found, don't reuse
    guess(i) = -2       // guess has been used, don't reuse

That's the entire black test.

White test takes a nested loop, but it's identical..