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

Next time you could EDIT your wrong post...

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

method of learning i use is to take up a book and start with the basics.. try simple programs for the each topics and then move ahead..

Nice idea -- if you are learning on your own. When you are taking a class you must follow the instructor.

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

When explaining a problem, explain the problem. Simply saying "It outputs it completely wrong..." tells us nothing. Explain exactly why it's wrong and also add what the answer should be. Don't let us guess. batAvg = singles + doubles + triples + homeRuns / atBats; is wrong. Use parentheses because the compiler does not understand how you want to group your operations. What you have there is basically batAvg = (singles + doubles + triples) + (homeRuns / atBats); because of operator precedence. Always use parentheses so you and the compiler are never confused: batAvg = (singles + doubles + triples + homeRuns) / atBats);

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

Gack!!!!

Hex 38 55 FD FF already is -174792! Just reverse the bytes because of it's endian-ness. You don't need XORs, bits, anything like that.

I used the string 7A 72 FC FF. I tranformed them to little endian (FF FC 72 7A). then preformed a bitwise xOR on them and got the value 14465896. However i should have got the value -232838.

Because you performed a bitwise XOR. Just reverse the bytes and you have it -- IOW stop when you get to FF FC 72 7A!

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

lol, it replaced : fs with the smiley , u know what i mean actually :P :))

That's why we insist on people leaning to use CODE tags, as mentioned in the rules you read when you signed up.

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

Your loop in lines 13-18 are missing a step.

Did you read the Rules? How about the post "Read This Before Posting"?

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

When you read the Rules as requested upon signing up, what part of using CODE tags was unclear? Or even the post titled "Read this before posting"?

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

Hey everyone.. I'm having a little problem with something I'm writing for a class.. I'm supposed to use while and a nested IF statement in the solution, but every time I run it I get the following back:

Run-Time Check Failure #3 - The variable 'A' is being used without being defined.

Well, where did you assign a value to the variable A so you can use if (Assignment = A) Also, check you book for the difference between = and ==

See this about your void main(). I hope your instructor didn't teach you that.

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

Well, it is "guaranteed" since mark192 says he is using windows XP and not necessarily looking for portability.

On the other hand, neik_e mentions portability problems which is true (+using a system cmd is costly) However, with careless use of i/o functions (buffer problems), mostly because of the mistakes that inexperienced programmers make, program might not halt. This does not happen with system "pause". This is the second reason why it is guaranteed.

So, how bad it is, it might become handy all of a sudden.

Try reading the link I gave and quit spouting crap...

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

// I haven't test this code, ...

Then you shouldn't be posting it. There's nothing worse that helping someone with code that doesn't work. (well, yes there is, but you get the idea :-)

invisal commented: What ashame, I made 2 mistakes in the row in 1 hour :( feel really bad now +3
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Another one for a guaranteed result;

system("pause");

That is not guaranteed for the reason neik_e mentions. And it's a very BAD solution! See this

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

Calculate the value of t1 and t2 then divide them.

Your post has all the information you need.

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

Here is some nasty code, I've translated it from Croatian. Hope it makes
sense.

However, sorting looks pretty nasty and it's written badly. Any suggestions
in changing?
I am stuck with the deadline, only tomorrow is left for me for having fun
with this code.

First of all, why aren't you using an array for news1 to news9? Wouldn't that make your program much shorter and easier to follow?

Why do you claim sorting looks pretty nasty and it's written badly? What is it you don't like about the code? Assuming it works (you never said it didn't) all I see is an inconsistent use of spaces throughout the program (usually in FOR and IF statements) making it hard to read. Add them around operators like for (i = 0; i < N; i++){ if (array[j-1] < array[j]){ all over the program.

Why are you using the LIST tag in your CODE tags?

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

IMAO Flash ads should be banned. They are annoying resource hogs. And Flash sites too. Flash should be used to enhance a site, not be the site.

iamthwee commented: A poor idea I'm afraid. -2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Require Positive Reputation Comment - Members must leave a comment in order to give a post positive reputation.

IMAO, all reputation should have a comment. I want to know why I got neg-rep more than pos-rep. Pos-rep I can figure out usually.

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

>2) use good code. What the h*** is
mul = (int)pow((double)base,(double) i++);

i m using vc++ there pow function takes double as argument so its called type casting.

So? Turbo C has pow() too, but you don't need it for this program. See the rest of my post you quoted.

>#2) Where is main() defined?
>#3) Don't you need some kind of header for pow().

i thought its common sense.

So why didn't he use them? Didn't you notice the post was not directed to you.

>2) use good code. What the h*** is

this is not my code, i have just modified it.

That'll teach you to use someone else's code you don't understand to try to help someone... :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
while((answer != english1) || (answer != english2)) {

It is guaranteed that one of the two comparisons is TRUE if english1 and english2 are not identical. Therefore the while is always TRUE.

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

i would like to add graphics to to the "8 queens problem" with a 8*8 grid colored in black and white with the 8 queens placed on the board and moving them using the arrow keys is that possible plz help me it is counted for my annual exam i've got to pass this!!

Have you got 6 months to learn how to do simple graphical programs? You are biting off too much if you have no idea how to proceed. Adding a graphical interface to a program is like converting a lawnmower into a go-cart. You have to learn how to create the graphical framework before you can drop in your code.

If you haven't been taught graphics, you'll pass without it.

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

>>do they contain anything in difference ???
Yes -- and IDE and a compiler and not the same thing. Is a dog and a monkey the same kind of animal?

Better analogy:
Car engine vs. vehicle itself.

The same engine (compiler) can be put into multiple cars (IDE). The car makes it easier to use the engine. IDE makes it easier to develop a program.

cant i just use visual studio from the command line ?

Yes. Check in the bin direcory for a short file name like cl.exe or mc.exe, something like that. At the command line, type in the name and a list should be displayed of all the switches available. First line of the display should tell you if it's the compiler.

I think your professor is an idiot and a jerk.

Tell him that an IDE...
Tell him also that...

Bad advice. You can't tell an idiot and a jerk anything without dire consequences. Just get a command line compiler and forget it. I use Borland 5.5
A little older but it still works great.

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

wollacott:
#1) Format your code.
#2) Where is main() defined?
#3) Don't you need some kind of header for pow() .
#4) Why are you using pow() anyway? You don't need doubles for this program.
#5) Don't make a new thread for the same program -- reply to the original thread.
#6) You can't possibly get an error about a function you don't use ( printf() )

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

Also, format you're code, please...

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

Also,

I've initialized the string "sym" to have the values '0' and '0'.

Then it's not a string, it's a character array. strings must end with '\0' (or 0).

I then call the function "cnvrt" and use "sym" in the parameter(not so sure if that's the right term) of "cnvrt".

Yes, that's the correct term.

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

DangerDev
Not only do we not do other people's homework for them, we try to
1) help them come up with their own answers
2) use good code. What the h*** is mul = (int)pow((double)base,(double) i++); :icon_question:
What's wrong with a simple r = (r * base) + digit; :icon_question:
What do we need doubles for?

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

Why do you have to disable cookies?

I'm reasonably sure that was a bad joke by WaltP, but I could be wrong...

Exactly... I use :icon_rolleyes: to denote satire in cases like this. I've been around long enough to know about cookies.

Today things seemed to be working. Let's see what tomorrow brings...

False alarm.... Still broke.

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

Since your post is unreadable, please read the Rules as requested when you signed up, the post titled Read Me: Read This Before Posting (the title says it all), and don't ignore the words on the background of the box you entered your post into.

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

Guidance #1: Don't bump your thread ten minutes after you post. Most of us have lives ouside of this forum
Guidance #2: Learn to format your code. I for one refuse to read code that I can't follow because of improper formatting.
Guidance #3: Read THE RULES as you were asked when you registered. It includes CODE tags.
Guidance #4: Check out the sticky posts at the top of the forum for additional helpful tidbits of information. Obvious posts will stick out.

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

That depends completely on how you set up the card data. The way I'd do it probably won't work for you.

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

Reread chandra.rajat's post and do what he said.

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

What you need to do is refresh the page the "first unread post" link is on before selecting the link.

What??!? Doesn't opening the page imply a refresh?

Also check to see if you have cookies disabled.

I have to disable cookies when I go to Daniweb. She's sweet enough without them... :icon_rolleyes: & :icon_wink:

------------------

Today things seemed to be working. Let's see what tomorrow brings...

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

plz help me

With what? A program someone else was writing in 2004? Get real!

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

That should work...

You should try testing your code before posting. That way you can actually say "that will work", and your code will in fact work. What you posted is an useless loop, so it can't possibly work...

And use CODE tags! Read the Rules.

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

can any one show me the code im suppose to be using and why ???

Isn't that a "please do my homework for me" question? We frown upon that. You need to ask for help and explain why you are stuck -- what is it you don't understand.

And learn to format your code properly. It's very hard to read.

Does this solve your problem??

It actually created more problems. Since you did it for him, he'll flunk his test because he didn't learn anything. He's now going to have to move back with his parents and get a job at Burger King because he can't program. His career is over before it even starts. Hope you're happy... :)

Not only that, your program didn't follow the instructions so even you flunked the assignment.

Create a text file with a letter on the first line, and two double-digit numbers on the second line.

You need to learn to test your code so you don't give people bad advice. :icon_wink:

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

what operating system will this program run on ? and what compiler are you using.

WE use kiel microvision...

Keil is a firmware compiler, so the program is the system.

I guess there is probably something else such as another thread that does something with P1 to make the LEDs change.

P1 is the LEDs. Set P1 and the LEDs change. It would be hardware mapped

Do you have an os-function similar to sleep() and Sleep() available ? Loops are a terrible way to implement a delay function.

Agreed. It's been a while so I don't remember the functions but I'm sure there is a delay function that accepts milliseconds as input. Ask someone that knows the compiler what that function is.

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

Rather than "the input is basically as string" just input a string. I don't know how you'll input "basically a string". :icon_lol:

Yes, you're logic is right on. Input the string. Then check each character to make sure they don't fall outside the base. Then convert the characters one by one into one integer and you have your octal/hex/binary value. Now you can convert it into any other base.

input string [I]str[/I]
set [I]number[/I] to 0
Loop starting at [I]str[0][/I]
    check if the character is within the base (if not, start over)
    convert the character to a [I]value[/I] ('0'=>0, '2'=>2)
    multiply [I]number[/I] by your base and add [I]value[/I].
End loop when you reach last character or \n.

Your loop end will depend on how you read the string.

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

Over 2 months (close to 3 actually) and still going wrong. Can we try to figure out what's different about my account that causes "first unread" to be "last posted" please? Dani, I know you mentioned something about waiting until the new VBulletin goes in, but that was over a month ago.

Please????

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

One problem you're going to run into is cin can only input decimal values. You cannot enter binary, octal, and hex natively. You'd need to enter them as a string and convert the characters into the numeric value. Then you'll be able to convert them to another base.

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

Yep, it's rubbish.

What you've posted is not enough for us to really help. You don't tell us what the variable types are so we have to guess. You don't have a default case but you claim you want to use one. And what that loop is supposed to do only you can tell. It makes no sense to us.

Post the entire program and ask a full question complete with what you want to happen and what current;y does happen.

And please get rid of system("cls"); . They just get in the way. If you really want them, add them back when you get the program running.

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

You need to learn how to OPEN and READ a file. There are a lot of threads here that show how, and there are tutorials all over the web. As well as books galore.

We're here to help, not to teach the basics you can find everywhere.

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

Hehe. I tried googling this, but all I've come up was Visual C++ results. How would I go about reading from a VERY VERY basic ini file in console C++ Using DevC++?

Why would VC be different than DEV?

Open the file
Read a line
Figure out what the line contains

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

Since an int defaults to decimal on input, and the largest value an int can hold is less then 5,000,000,000 it's no wonder entering more than that doesn't work.

You can change your code to enter a string instead an int and process the number character by character.

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

Can please post the code, If you are done with the problem............

I am working on some what similar problem for one of my assignment :)

Maybe you should read the rest of the thread to learn how the problem was solved rather than asking someone to post their solution to save you the trouble of learning to program.

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

My view is that the ladder should be wider at the bottom but this modification of the design is only usually seen in agriculture.

Construction too.

Perhaps GBS would not have died if he had used a scaffold tower -which is virtually fool proof.

You've never seen "The Money Pit", have you :icon_twisted:

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

The main point is to use some of the sorting algorithms. Any suggestions, ideas, pseudocoding since I am newbie?

Do a search for Bubble Sort. It's the easiest to understand and for the small amount of data you need it should be more than adequate.

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

It worked, thanks!

Now, what did you mean in your first post?

> The code you posted has a major flaw though. You don't want to check the entire size of the buffer szword but only the number of characters the player typed. In C that would be strlen(szword).

oh, and yes, I am working with an std::string.

He means if you entered 3 characters, say NOR, for NORTH, the comparison won't work. You need to compare only the first 3 characters of your internal string.

And why capitalize the first letter of the sentence? Just force everything to lower case.

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

Build a system that even a fool can use, and only a fool will want to use it.

.............

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

What about a cell phone number. And maybe birthday.

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

I believe what he's saying is that there should be a START NEW THREAD button on the actual thread pages, next to the REPLY TO THREAD button.

IMO, that doesn't make sense.

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

but how can the c++ detectthat the data is student id and examcode?

Please take care in your posts. detectthat? foleslike?

C++ cannot determine what type of data it sees. You have to determine what the data differences are and program the code to understand the difference.

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

i have another problem...! do you know about a star algorithm? our professor required us to put this kind of algorithm to our program..so does any one know what's this algorithm and how it works? also how will i incorporate this algorithm to our program..tnx...

If he requires it, he should describe it. So ask your professor. :icon_rolleyes: