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

The results of a factorial calculation are positive integers, so you were fine leaving it as int. To extend the range, you could use unsigned int.

If your value is larger than an int can hold, how is it fine leaving it as an int? Isn't the double giving you the ability to have a larger value -- beyond the capabilities of int -- albiet as an approximation due to magnitude?

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

Good question.

Write a short program and output the value. Does it compile properly? If so, what does it output?

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

from what i understand:

  1. char==1byte==8bits
    therefore, if i call 'ch' a char variable, and assign it value 5, then binary ways:

ch= 10000101 (signed negative char)

How do you get 10000101? Where did the first 1 come from? What you have is -123. Just because it's signed does not mean the first bit is 1. It just means the 1st bit is used as the sign bit.

My question was referring to what happens when you have something like

int a;
char b;
a = b;

Is this safe? What happens to the values when you assign values to a different type? This also affects:

int a = 23;
int s;
sqrt(a);

since sqrt() takes doubles, not ints. What happens to the int ?

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

Why are you using fscanf() to read a single character? The overhead is tremendous. fgetc() was specifically made to read a character. It's small and concise.

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

Well I found that difficult to read.. You should really really format the code properly before posting it. I know it only takes two clicks to format it A-style but meh. If you did so, more people would take the time to read it.

Two clicks of what?

Also I'm not sure how you got that to compile because there is no cstring.h and no iostream.h

Remove the .h from both of those headers and it'll compile fine.

Also you have quite a lot of compilation errors. If you aren't using std:: infront of standard library functions, then you need to have using namespace std somewhere at the beginning of your code.

You don't seem too be familiar with Turbo-C.

Main cannot be void! It must return an int.

This is true...

Also after std::cin>>info[i].id; you should use std::cin.ignore(); or else it will skip the next line due to the enter/return button being pressed. It needs some error checking for that as well because if the user enters a string, your program will end immediately!

Probably true -- didn't check close.

Switch the getlines to cin>> with a cin.ignore.

Wrong. By switching to cin>> when you enter anything with two words, like an address or a last name like "van Dyke" or "van Halen" all you get is "van". Leave the getlines() alone. You want to read the entire line.

If an if-else statement has more than one command …

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

Count them as you input them

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

Please explain what you think this definition means on line 59?
float Student_Financial_Data::getScholarship_Money(int getAwardAmount())

What is the parameter being passed in?

// student_Data.getScholarship_Money(getAwardAmount()); <========== why doesn't this work???

Define "doesn't work"... Compiler error? Sementation fault? Makes coffee bitter?

Always explain your problem, don't make us guess what is happening...

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

Some things you need to figure out:

1) What happens when you pass a character variable to a function that wanted an integer?
2) What happens when you return an integer into a character variable?

Are these safe?
Do you need to convert first?

Research them...

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

I think it's leet for duh

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

Or you can call atoi() and not have to actually write the code. ;-)
Look it up...

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

What's q=((2*i)+1); supposed to be doing?
If you wan tthe factorial of 7, why are you passing 15 to the function? Won't that give you 15! ?

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

Do i have to start a new discussion whenever a question is solved?

Not if it's a continuation of the original program. Although if you mark it solved, many people will bypass the discussion.

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

How many bytes does ip point to? None... You defined the pointers ip and op but no actual space.

You are making it too complicated. What did you read into input? At least 2 characters, and up to 40 (that is if your fgets() was right - which it isn't). So just look at the first character and you're done...

short int2shrt(void)
{
    char input[40];
    char  ip;
    short op;
    printf("enter input:\n");
    fgets(input,39,stdin);        // note the correction
    ip = input[0];                // this is the character you want
    printf("You entered %c",ip);  // remove the *
    op = ip;                      // just load it...
    printf("the output in type short is: %h",op);
}

I made minor changes to almost every line. But this is a lot closer (and easier) to what you want.

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

It's because some compilers only do the actual output when either
1) the output buffer is full.
2) you fflush() the buffer.

Most of the compilers we run across on the forums must have the extension written to flush the buffer before returning from the printf(), but it's not something you can count on for all compilers.

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

You are overthinking the problem, trying to solve the problem from the wrong angle.

What did the link say about entering character strings? I know there was a recommended input function. Using that function will only complicate the reading of integers a little, but the input stream will be kept neat and clean. You won't have to worry about extra characters as long as your input buffer is adequate in size.

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

Don't worry about it... It doesn't concern everyone.

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

array = new int [size];
Wrong syntax. Look up the correct syntax again.

Also, what is the value of size at that point of the program? Hint: It's probably not zero.

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

yeah thats true :( but then i was looking for what scanf() does for my college homework.. and in college they used scanf() for everything!

Let me guess -- Turbo-C; India. Am I close?

one thing i would like to ask is that if there is any way i can see exactly whats in stdin?? whitespaces and everything? i read fgets() keeps whitespaces.. what about other ones? does it keep them too?

Depends on what you mean by see. It's not easy to see what's in the input stream. Since you mentioned stdin, it's every single key you pressed. Function and special keys have special codes and won't normally be in the stream.

Start a loop 
    Use one (and only one) type of input into a character buffer
    Another loop to output each and every character in the buffer

Break out of the program using Ctrl-C, or loop at least 3 times.
Then compare and see which keys you pressed are not in the output.

bdw, the examples in your link really helps :) thanks :)

Welcome.

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

Anything here (including GDC I suppose, if you want) but not with recursion. Unless you can prove to me recursion uses fewer resources than non-recursion.

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

This is totally a bug. Clicking the arrow should never take the comment. I think this bug is what was causing the problems with the comment not showing up unless you refreshed.

Please don't fix it! Or if you fix it to correct the other problem, make the arrows function like this anyway. I'd rather click the arrow than see the comment I just made -- I just made it after all.

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

You guys are quick! Only 14 minutes

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

I guess it was a bad idea to ask for help here.

Actually, it wasn't. You just didn't ask one that could be answered.
I take it back. You never asked a question at all -- in any of your posts. So don't get huffy with us!

To sign off on this thread, I'll give you all a quote from my project:

And I'll finish off with a quote from the garment cleansing industry:

No tickee? No laundry!

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

Reply #3

That should give us enough to play with...

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

Reply #2

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

Reply #1

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

Use this thread to test rep

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

Can someone please clear this up and state exactly what happens in the following scenarios?

Based on my tests as a moderator:

1. I click the up or down arrow without entering a comment
The post is voted up or down. No rep change

2. I click the up or down arrow after entering a comment
The comment is logged and rep is changed based on the arrow.

3. I click the gadget to the right of the comment field (in other words neither the up or down arrow) after hovering over the Up/Down arrow to change the gadget to either Up-Vote or Down-Vote.
The comment is logged and rep is changed based on the arrow that invoked the comment box. The gadget informs you which arrow is active.

Find any of my posts in the C/C++ forum and play around. If I get too much neg rep, though, your posts are in danger!!! :)
[edit]Note: Doing your business in this forum does not alter rep[/edit]

[edit2]Better yet, use this thread[/edit2]

Note to self:
3,415 Reputation Points

Last logged rep (reversed):
fdsfds — iamthwee, 2 Hours Ago

Last actual rep:
Giving you negative rep ... test — Dani, 2 Hours Ago
Thank you, I'll remember that! ;)

Reverend Jim commented: I have no idea what I am doing anymore. +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First I get complaints galore that there's no undo feature. So I implement one, but that's not good either. sigh

I understand the complaints and agreed. There should be an undo feature. But it wasn't fully designed. I'm not saying you did a bad thing, just not a complete thing.

The arrow has a little undo icon ... shouldn't that indicate something?

Yes, it should.

The solution wasn't to simply add the undo function. It needed to be further refined from a user standpoint.

If there is an undo indicator, do not open the box to input a comment. Replace the box with the message "Remove the current vote" or something to that effect. Then there would be no confusion and the user is happy knowing exactly what is going to happen.

You gotta understand, I've been designing user interfaces since the 70's so I'm a little more sensitive to unexplained phenomena as a user. I'm not just complaining for complaining's sake.

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

I doubt this. ;) Are you sure you're not just giving a +1/-1 vote??

See this post and check his rep:

Updates version Age Calculator --------- + 14 reputation points
Testing where rep counts. — WaltP, 11 Seconds Ago

All done by arrows.

It works as intended. First time is a vote. Second time is a reversal. Third time is a new vote.

But it is not intuitive. It I type in a new comment, I would not expect the previous rep to be removed and this rep to be ignored. I would expect 1 of 3 possible actions:
1: The comment is replaced
2: The new comment is added to the old comment
3: The new comment is another separate vote

I would not even consider that the message I typed in would be competely thrown away.

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

If you want to close the program from somewhere else then call exit()....

But only if you are not in main().

And if you are in a function, it's still best to try to return to main(), if possible, to exit (using return of course).

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

You can use recursion to find GCD.

Why? What's wrong with a simple loop? Less overhead, easier to read... And why not just calculate the LCM? Why go through all the GCD calculations?

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

I also tried to replace the whole code to another function, AgeCalculator(), and to fill in at main() to jump immediately to AgeCalculator(). I replaced alle main()-statements by AgeCalculator()-statements, and I got exactly the same result. Nothing happened, so I changed it back.

You were supposed to get the same result if you programmed it properly.

But, now I am working to another update. This time I will use abort() to close the program. That's the most efficient way, I think.

Wrong... It's one of the wort ways.

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

Dutch words are good readable, and they look like the English words.

There are very few words that start with BJ in English. There's BJ Hunnicut from M*A*S*H. Hmmm, that's the only one I can think of. Oh, and Bjorn Borg. No, wait, he's not from here, is he? ;o)

Honestly, I agree. With the prompt "Enter year" it's somewhat obvious what bjaar means. Not that we can remember 20 lines down, though...

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

Please note that clicking on an arrow does NOT give reputation. Reputation and comments are only submitted if you click the form button or hit Enter.

Not true. I've been clicking the arrows and rep has been given. If this is a bug, please don't fix it!

Also, look at what happens when one person gives rep to the same post two or more times. It's a little screwy.

Dani commented: Giving you negative rep ... test +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Oh, those lucky people....
This is completely non-intuitive.

Also, you might want to look at what happens if 2 comments are made by the same person on the same post. It's really screwy.

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

Is there a reason I can not do that with this code?

Probably because the file isn't in the same directory as the .exe, as already explained.

Alternatively you have debug turned on and it needs to be in the debug diectory of the project.

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

And even though I hovered over the down arrow, I can still click the up arrow anyway. An acceptable compromise...

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

When I delete a post (as least one of my own) I click the DELETE button twice before it changes to UNDELETE. Sounds related to the refresh somehow.

Is it just me, or when you vote with a comment, does the comment not instantly show up like it's supposed to??

I didn't know it was supposed to since it never did for me either.

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

If you consider MicroSluge awesome, I suppose so... 8]
IMAO, I'd change color schemes quick so as not to be assiciated with them :o)

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

Why would the creator be important? Isn't the content the important thing? You could have saved yourself a lot of time and trouble by not vaguely reading it the first time, dontcha think? ;o)

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

So return it, don't pass it in.

You are inputting the value directly into the class variable student_name so you don't need to pass anything into the method. By passing it in, I believe you have created a local variable and bypassed the class variable.

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

uhm... WaltP, point 4 on your list is not "main" but "menu"... and I believe it can be void...

Yep, read it too fast. Sorry.

and the semicolon in point 3 is an end while the rest should just be spaced into a new line as an variable of the struct (I hope I said it right)

I suppose so... But if you weren't even sure ;)

Ron Walt is correct on his points though he seems very irritated

Don't make snap judgements about people's states of mind. Keep your opinions to yourself in regard to mental states. You don't want to put a bad ligth on a member for no reason, and it's quite close to a rules violation.

and quick to show out problems,

Should I have waited an hour? ;o)

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

1) Stop putting your question into your code. Your question is not code.

2) #include<conio.h> -- don't use this. It's not standard and is not necessary.

3)

struct BuyerInfo
{
 int id;
 string fn;
 string mn;
 string ln;
 string ad;
};BuyerInfo info;

Why is the first semicolon in this line: };BuyerInfo info;?? And indent the fields more.

4) void menu() -- main is and always has been an int.

5) void main() -- twice? That's bad.

6) You don't define your array on the structure name. The array goes on the variable name.

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

1) side1 has no value so you are passing junk onto myTriangle.setside1()
2) myTriangle.setside1() is a void function and returns nothing, therefore you can't load that nothing into side1

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

You know, you could ask a question or two that will lead us to understand what you are having trouble with and actually be able to lead you to a solution or two.

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

It's not weird at all. It's lack of understanding how scanf() works. Here's a series that explains the problems you are having. This will also help you next time you need to mix integer and character input using

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

I would suggest you open your book and look at the chapter on arrays. your question is sooooo basic that it's in there.

Eagletalon commented: Correct way to assist, reference to answer and not spoon feeding, brilliant +3
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why are you passing the variable (note: variable) student_name into the .getName method? Shouldn't the parameter list be void?

And, because .get methods generally return the internal value stored in the class, shouldn't your method be called .inputName()? Just a thought.

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

Interesting... Did someone actually type in each page of the book for the .pdf? Rhetorical question...

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

No, but that's what 1 is -- an integer. And what you input is a character.