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

Standard C doesn't do color.

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

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why? You asked for help before and refused to supply requested information.

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

Read my post.

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

CODE TAGS
... read any of the requested information posted all over this site about CODE tags, like
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) Even on the background of the box you actually typed your message in!

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

You are attempting to read XXX into your integer values.

Why are you reading in so many places? Think through your design again.

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

I can't even follow your code. Please learn to use proper and consistent formatting so those you ask help from can read your code.

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

Before printing use an IF statement: if (lastCharEntered != 'p') print

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

I repeat:
Think back on your elementary math. How do you get decimal values using whole numbers?

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

the assignment says i can only use variables of type "int" so my question is how to print the average to 2 decimal places using only int and not floats.

Does the assignment say print 2 decimals using only ints?
Think back on you elementary math. How do you get decimal values using whole numbers?

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

I don't know for sure. I don't do Windows Forms programs. I think it might be possible.

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

So, then add all the input values.

If that doesn't help, explain again in greater detail.

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

My code needs to run a sum

How do you do that? What do you need to do to run a sum?
Forget C++ for the moment and explain the process to me...

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

Forget the new operator. You don't need it.

I have it somewhat ok, until the end where it's supposed to give the average. I tried a couple things but none of them gave me the right answer.

What's your definition of "somewhat ok"? If it doesn't give you a proper answer, what's OK?

I don't think I'm keeping track of the sum either.

How can you tell?
What do you need to keep track of a sum?
If I give you 5 numbers, can you keep track of the sum on paper?
If so, how did you do it?
Do the same thing in your code.

Think through the problem, then code. Don't code, then beg for help.

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

And that's the problem I'm having, how do I add the null character???

No, what the problem you have is that you refuse to think about help the help given and you won't answer important questions:

Think about it... What kind of character array(s) are needed to do this?

How do you tell when you've come to the end of one word and the start of the next when looking at a sequence of characters?

Neither question was even considered.

And I already showed you how to add a null character.

I therefore suspect your question is not addressing the real problem you are having. But you haven't given us enough details to understand what that problem really is.

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

You can't assign a string to a float value. You have to convert the string into a floating point number. Look it up. Key word is convert

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

Here's something you may want to look at.

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

Think about it... What kind of character array(s) are needed to do this?
Try something... See if you figured it out.

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

You can't be getting you data as a string since NUL cannot be part of a string. SOH is questionable too.

You are getting your data ins a character array.

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

Find the end of the 'string' -- the last character
Say it's array[x] Set array[x+1] to '\0'
The char array is now a string.

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

I wanted to write a program to check if string entered is a palidrome. I wrote a program but i get errors while compiling. Can anyone help me identify errors in the program.

Are we supposed to guess what the errors are? Or would you like to tell us?

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

Let's see if I got this right.
Your school banned system calls.
You want to bypass that ban and make system calls anyway.

Sounds to me like you are trying to do something they don't want you to do.
Do I have the facts straight?

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

Honestly, I have never done anything like that.

So? What's your point? You never programed before either. in your other classes have you never thought of a technique to help you get your homework done that wasn't directly taught?

We never learn how to do that in class, we usually just type everything in exactly the way the professor does it. Which is probably why I am always so confused when the homework is really different than what we did in class.

Have you ever taken a class before where you had to think? Not just regurgitate information a talking head tells you? Well, in programming you are required to think.

If I looked at this program I would have no idea what anything does, except for the opening of the files, and returning an integer because main is an integer.

Then why are you writing all that other stuff? If you don't understand what you're writing, how do you expect to get the program running?

But I ended up writing a program that worked, so for now it's good.

I doubt it

Although I probably should learn what each line does.

Ya think?

Sorry if this sounds harsh, but you've got to start learning what he's teaching you. You can't fix a car without knowing what you are doing. You can't wire a stereo without thinking about where the wires go. And you can't program without thinking about what you are doing and what you …

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

You aren't listening. Try to learn something...
Look up conio.h in the C Standard...
Look up the information in your link in the C Standard...

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

Print your program.
Sit at a desk with the program and a pencil.
'Execute' your program line by line, loop by loop.
Write down the variable names.
Write down the contents of each variable as they change.

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

How would a loop for 1 digit be useful? :icon_rolleyes:

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

Use Lisp or Snobol

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

printf("%f", b);

This only outputs a float, not a double. Try %lf

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

Use a loop to reverse the numbers into your temp array. It's bad form to to do all your work in one statement like you did. Do one simple step at a time. It's a nightmare to debug the way you have it.

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

So why didn't you mark the thread solved?

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

You're making it complicated with two DO loops inside a FOR loop.

Find the first "
Start a while loop until you find the next ", copying the name
Skip past the "
The rest of the line is the number, just use atoi() at that point.

Of course you still have to make sure the second " was found, so you can trap an error.

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

This thread is stupid -- and closed.

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

Simplify the statement so you can see exactly what is going on.

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

But I'm working on 2 512x512 matrices and when I try to find the Correlation it produces a number like: 1.64643e-14 which is obviously wrong.. I have tried everything..

What is obviously wrong about it?

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

When you get to this section of the program that executes:

//enter gender
    cout << "Enter Gender: ";
    cin >> gender;
    gender = toupper (gender);

how many and what keys are pressed?
Are all the keys read by the program? Why or why not?

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

I did help. Ask a question.

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

If getch() isn't available, see gcc equivalent for getch()

And what if you aren't using a gcc compiler?

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

bharat please show me what to do.
im really inexperienced at this course...

Really? You haven't take it 3 times yet? You must be inexperienced...

... and i could do with some help.

What you can do is ask questions. We can't read your mind and clear up your confusion if you aren't specific in what's confusing you.

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

You want us to do it for you? Or would you like to ask a few questions?

Reread what you posted and try to think of possible help you can get based solely on your post.

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

The main problem is you aren't 'dealing' the card. It's still in the deck.

Your first card is j = rand()%52; Then remove that card from the deck (shift all values from j thru 51 down 1 entry.
Now you have 51 cards left, just like a real deal.
Now you deal the next card with j = rand()%51; Or, if you have the deck shuffled, just deal from the top - 0-9 for 2 hands of 5 cards.

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

Assuming you won't have any input like
Victor Von Doom St. Louis
Dick Van Dyke New Rochelle

Use 3 while loops and 1 index into the buffer.
First and Second while copies until a SPACE is seen
Third copies until a \0 is seen.

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

Based on your explanation, I take it you have more to do on the program, but since you didn't ask any question nor explain any problems, all we can assume is you're on track.

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

You can't. scanf() requires an ENTER.

And why is continue plural?

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

A more generic way would be to first convert the int to string, then copy the digits in reverse order (from right to left) into another string adding the commas. Finally you will have to reverse the result string because it will be backwards. std::reverse() will do that.

Unless you copy into the string starting at the end of the destination string.

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

Is it Dangerous to Derive from STD? Specifically std::string.

As far as I know, no. That's why objects exist. You start with an object that does most of what you want and add more functionality to it for your specific needs.

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

arrays start with 0, the [12] is a null which is used to indicate the end of the array.

No, the [12] is not a null, it's the next variable in the data area. [11] is the end of any array with 12 elements.

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

in coding, how do you actually track down the bug??? example this code where we want to find the quartile....

Too late now, but before you write too much code, compile and test in smaller pieces.
Now, start outputting variables at key places to follow what the code is doing. Compare the values output with the values you calculate they should be.
In this case after the sort display the sorted values.
At line 28 display the value numberstore.size() .
In the for loop, output the values being computed.
Etc...

Vasthor commented: ha3 thnx, never thought 1 month leaving make me forget of this step xD +3
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No. They wait for the ENTER to be pressed

jaskij commented: My bad :( +4
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What about it?

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

4 posts -- all very poor. Maybe this will help you get better help, by giving better information:

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a …