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

Try the documentation for the compiler.

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

But there is this thing I can not fanthom, how to check if the game is not over? You check that by seeing is there are any valid moves left. And I am familiar with the rules of othello which confirm what a valid move is. But I can not put together the conditions of a valid move.

Turn the computer off.
Write down the rules.
Which one is most important? How would you test for that condition? Write down the steps.
Which one is next? How would you test for that? Write down the steps.
Keep it up until all the rules have bee tested.
You now have the basis for your test algorithm. Convert the algorithm into code and go through it over and over --step by step -- until it seems to work for all conditions.
Then, and only then, turn the computer on, type your new code into a function, and test test test.

And I was thinking if I could simply place a while loop until the game in not over and inside the two human vs. human players take turns and the game proceeds for valid moves and exits for invalid moves. Will the while loop work?

Yes.

Now, I think of it, if I have to take manually the use input everytime, when do I know how many times I have to ask for input?

What???? I have no idea what …

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

So

hits[r]++

is adding 1 to whatever "r" is in this case. What is the relevence of r in the program? I don't see it everying printed out or used in any way in the cout<< statements.

No. It increments the r th value of the array hits. IOW, if r=3, hits[3] will get incremented. r will not change at all.

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

with no luck,

Meaning what? Compiler error? Outputs wrong stuff? crashes the computer? Creates a black hole that sucks in the known universe?

What exactly is isalnum(str firstin) trying to do? What's str?

how do I make it so that it only operates if the first input is a number, I tried to use the ctype.h functions

If you want only a number, why are you using isalnum()? Does that work with only numbers?

Also How would I do it in a way that a new string is declared when needed, but not here if not needed, (Example: Print Hello is two inputs, but 1 + 8 is three inputs?

And 1+8 is one input. Read the entire input as a single string and look at each character to decide what was entered. It's called parsing.

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

When I use bold followed immediately by italic, the WYSIWYG box shows the post properly. When posted it does not.

**Bold***Italic*
The above shows properly before posting.

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

Close. he functions returns a value from 0 to n-1.

hits[r]++;

hits is an array. Increment the r th element of hits

cout<< static_cast<double>(hits[i]) / (n / 10)

Break it into it's pieces based on the parens and you'll see. Or be more specific in what you don't understand.

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

Does this mean I have to create a new project everytime I want to run a single program?

Yes.

If you made chili in a pot yesterday, would you want to make tomato soup today in the same pot with the leftover chili?
You either
1) clean out your pot
2) or get a new one.

Humayoon Khan commented: haha nice =) +0
amrith92 commented: haha, nice one! ;) +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Almost enough details for understanding....

Do you have a function defined to read a line and do something with all the other data yet?

Let's see how many more questions we need to ask.

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

What part of "small, complete program that exhibits the problem" was unclear?

Considering "Hye i am running difftime tu different 2 time values" my guess would be all of it... ;o)

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

is the problem because of the compiler?

No. You have C++ Strings and you have C-strings. Both are different and not interchangable.

Some functions have been designed to use C++ strings; some use C-strings. The documentation of each function tells you which one you need to use.

Some compilers will make extensions (added abilities) that the standard C++ definition does not describe. If both C-strings and C++Strings work in VC++ they made an extension so it will work for their compiler but not others.

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

Test each value entered. Make sure something was typed in. Are string.lengths greater than 0? Are numbers not 0?

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

Ask for input
Accept input
Figure out what block the input signifies.

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

Suggestion #1: Do your compares case-insensitive so that binary, Binary, BINARY, and bInArY use one single compare.
Suggestion #2: Put all the questions (and answers) in a file. Have the questions sorted alphabetically and read them into arrays. Then look up how to do a binary search. That will make the program extremely fast.
Suggestion #3: Get rid of conio.h -- you do't need it and should not use it. It's non-standard. out of all the compilers available, only a couple mavericks support it, and even they support it differently

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

Since the context of your second statement is unknown, and, as it stands, is false, I think you are confusing two different problems thinking they are the same.

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

What format is the time in the file? Binary? Text? Other?

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

1) Turn the computer off.
2) Sit at a desk with pen and paper
3) Write down the functions you need to create (add, delete, search, ...)
4) Take each one at a time and write the steps needed to accomplish them -- in great detail
5) Run through the steps a line at a time adding, deleting, etc. untill you know what you wrote works well.
6) Turn on the computer
7) Translate what you have into code.

This is the best, fastest, easiest way to program. 80% at a desk, 20% at the computer.

Think of anything that is to be created -- building, car, whatever. How much time do you imagine is used designing the thing vs. actually making it? The same with programs. More planning and design than typing code.

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

I can not find the problem of this code.......

After 300 post one would think you'd know how to ask questions by now.

Always explain why you think there is a problem. If you don't tell us why you think there's a problem (error messages, bad output, whatever) how do we know what to look for?

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

The answer to the first part of your question is provided in the link I posted above.

No it isn't. All that's provided in the link is a possible way to halt the system given the circumstanses set forth in the problem definition. It has nothing to do at all with the problem stated here.

The answer to the second part of your question was provided by Sokurenko.

Really? All he said was program properly and you won't have a problem. Where have I suggested not programming properly?

'm not sure I understand what you mean here. Either this is homework or it's not.

Being homework or not is immaterial, unless you are saying there are homework rules and non-homework rules.

I am making no assumtions. Your assumtion was how the input is being made as shown by linking to that article. I have no idea how the input is designed therefore have not commented on how the input is going to be dangerous with a large array vs. malloc/realloc array. AAMOF, the dynamic memory situation would be identical even in the link you posted. Try it...

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

This is homework

Really? What makes you think so?

You waited 1-1/2 years to make your first post with this newsworthy information???

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

Turbo for Windows 7 64 bit doesn't exist... The last version of Turbo was created in the early 1990's

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

@WaltP: I was thinking about that, but when I sort it, I will have to deal with all the zeros at the front.

Why? If you read in currentCount numbers, why would you sort the entire array? Just sort the currentCount values entered...

Also, I've got another project which i might need to make a 1,000,000 sized int array and the amount of memory (or something else) crashes my terminal when using codeblocks IDE.

This is what malloc() is used for. Large arrays that won't fit on the stack.

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

While this would work if this is just homework, it's not a good idea in general, as it creates a huge security hole in the application

How does this create a huge security hole and reallocating the array by 1 for each input doesn't? Keep in mind the info we have been given by the OP, not making unfounded assumptions about what we haven't been told...

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

I have been looking at my loop structure and functions for a while now but cant seem to find the problem. I need another set of eyes to look it oveer and see if they can't point out the problem to me. More than likely it is just a simple programming error but any help would be appreciated.

You didn't explain the problem so what can we say? We have no idea what we're looking for.

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

char sentence[100000];

How many words do you know are 100000 characters long? Wouldn't a shorter 'sentence' be better? And if you only want words, would a variable named word be less confusing than sentence? ;o)

Also, while(!inf.eof()) -- see this

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

Why not just create array as a large array? Say int array[1000]?

The concept of increasing the array size by one for each and every value entered is so resource heavy that I don't really think a useful solution.

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

Since you need to keep track of a whopping 8 moves, a stack seems to be overkill. Just add each move to an array.

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

After 7 years one would hope said junior computer student has been in the industry for a few years and can finally understand pointers... ;o)

Maybe it would be better if people stop resurrecting long dead threads with worthless posts.

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

Now, the second while loop (line 4) I don't understand. What happens first? The assignment (base)=(add) and the increment of pointer positions? Or the other way around? First increment of position, and then assignment.

Think about how a while loop works. In general what's done first -- the comparison or the inside of the loop?
In other words, given while (A) B;
Is A first, or is B first?

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

I don't really see the problem, to be honest.

If you don't understand anything the teacher says in class you need to talk to him one on one to explain what you are having trouble with so he can explain it in ways you can inderstand. You obviously need more personal help at this point -- books, tutorials, and forums won't give that to you.

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

For what it's worth, / vs \\ is a non-problem. Generally in C/C++ the languages treat both the same in file paths.

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

walletfile.open("C:\accounts\wallet.acnt", ios::trunc);

\a is CTRL-A
\w is CTRL-W

In C++ if you want a \ in a string you need to double it:
walletfile.open("C:\\accounts\\wallet.acnt", ios::trunc);

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

How did you find the website before? How do you think you can find another website with similar information?

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

We need to know what types wallet, account, and savings are.

No we don't. What types they are are irrelevant to the problem.

Add couts to follow the program flow to make sure you in fact are entering the function. And as Labdabeta suggests test (and display) the status of each open and write.

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

No.
Anytime we have to wait because an ad takes over the screen, even for a few seconds simply because we move the mouse, we get annoyed. Just because it's rampant across the web does not make it more acceptable to the user.

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

If you accidentally hover over, you have to wait for the fade effect to go way.

I would find this exceptionally annoying. Every site that has those green underlines piss me off every time I move the mouse...

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

See this. Check out the rest of the series, too.

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

I'm sure stringstreams are not available for you, so you probably need to use a more mundane approach.

But it depends entirely on if you use C++ strings or C-strings.

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

the code I have is not working. please help.here is the code

Can you possibly be less vague?
1) What's "not working" about it?
2) Where's the formatting so we can actually read and follow the code?

When asking a question, don't be vague. Be detailed. With examples and explanations. And use formatting...

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

I need your help regarding the message acknowledgement in the queue when the message reaches at the queue.

Sorry, no idea what this means...

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

You ask a question that cannot be answered because there is no information given for us to understand and deceptikon is a moron? Check your mirror.

And you also make threads with urgent and plzz in the title in violation of the Member Rule "Do use clear and relevant titles for new articles". Neither title is clear nor relevant.

Then further violation of member rule "Do not post insults or personal attacks aimed at another member" just because you can't form a question properly.

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

With what? Code with no question does not require a response.

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

So far you've only given vague information. You need to be specific in what you need help with and post code that shows what you are having trouble with. The more detailed the information, the more good help you will receive.

So far, our best response to

I am a bit weak in functions writing. can anyone help me please?

is "yes". Nothing more,

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

how to make sure the same digit is not used twice?

If you use it once, remove it from the list.

For example:

for(i=0; i<4; i++)
{
    if(guess[i]==random[i])
    {
        printf("#");
        guess[i] = -1;  // remove the guess since it's been used
    }
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i need some way to print spaces after the snake so it doesnt leave any points behind or a way to make the food function not to generate random points everytime

You know what the last position of the snake was, so just output your spaces after you output the snake.

PeTo. commented: I've done that , but now i need a way for the snake to keep moving without having to press a key a key each time +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You've been given 2 possible solutions. Try one.

PeTo. commented: I tried different solution but hasnt worked for me :D and now i'll try the first solution :) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You first read a line from the file -- and do nothing with it.
Then you read the first character of the next line and do worthless stuff with it if it's not SPACE.
Then you go back and read the rest of that line with fgets() and do nothing with it.
Then you read the first character of the next line and do worthless stuff with it if it's not SPACE.
Then you go back and read the rest of that line...

You need to learn how to desk check your program. Sit at your desk with pen and paper and go through the program line by line filling in variable values as you go. Check to see if what you wrote makes sense.

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

You need a FOR loop to move each piece of your snake.

PeTo. commented: i'm trying to make one but out of ideas ! :( +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I would want an example from you since your description of the problem makes no sense to me. Show is what you are trying to accomplish and your attempt at the code to accomplish it.

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

Butin the FOR loop you don't care how many loops it takes. Just wait for x to become 0.

As I said, find the pieces of the WHILE loop code that correlate with the pieces of the FOR loop and plug them in.

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

You will never use malloc() or calloc() in C++. Ever.

Wanna bet??? ;-)