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

Can't read it. After 140+ posts you should understand formatting by now.

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

Me:
Count the A's, SPACEs and -'s in each line, and in each section of each line.
Look for numerical patterns.
When you see the patterns, write down some calculations that you can turn into code.
Use lots of paper, and analyze analyze analyze. Plan plan plan.

You'll need a few loops for each line.

OK, I guess you don't have to do any of this. Just convert Lucaci's pseudo code into real code. He did the hard work for you.

Be sure to thank him.

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

Count the A's, SPACEs and -'s in each line, and in each section of each line.
Look for numerical patterns.
When you see the patterns, write down some calculations that you can turn into code.
Use lots of paper, and analyze analyze analyze. Plan plan plan.

You'll need a few loops for each line.

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

Appearently you fail to grasp anything so I make it clear: In case it wasn't obvious in the other thread I don't agree with not posting solutions so this was formulated in that specific way as a slight ridicule towards it.

Ahhh, I see now. It's Mr. "I Know More About These Forums Than Everyone Else".

Problem with your logic is:
1) you are expecting us to remember one post you made elsewhere out of hundreds we read daily
2) sarcasm requires knowledge of the one making sarcastic remarks. All I understand is from what you posted above.
3) on a forum, a smily generally hints at sarcasm. No smily, you must be simply daft.
4) whether you agree or not, you are not to post working answers. Period.
5) better reread the member rules. They are important here, whether you agree with them or not.

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

First problem I see is the use of GOTO. You should rework the program to use loops instead.

Since there is absolutely no context, no comments, and no explanations of what anything is in the code you posted, there is nothing we can tell you about your code.

I can only suggest to solve the duplicate problem is create an array of 26 values representing the alphabet. Zero the array. Every time a letter is guessed, check the array. If 0, change to 1. If not zero, it's already been guessed.

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

Probably because loops are still too hard

He's using loops now.

I would say he's learning loops now ;-)

I never mentioned vectors or any higher level stuff, just recursion.

But everyone else does when arrays are used. It was a blanket "stop suggesting sh!t beyond the noob's level" comment...

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

No offense, but this statement makes you seem childish and bitter.

What I find interesting that rather than posting the statement

Ignore the above it would be an answer so it's evil and totally stupid of me to post

and making himself look... well... you know... he just didn't delete the explanation himself and not post it.

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

Any particular reason why this isn't good enough?

Probably because loops are still too hard and recursion is taught two classes beyond this one? Remember, just because you understand recursion and vectors and all that high level stuff does not mean someone in their first class has ever even heard of them, let alone been taught it.
8-]

so if the first element of the array does not equal the second element then the contents of what Walker is pointing to gets assigned the first array element. Walker is then plus plused so that the next time array[i] != array[j] we don't replace the the same thing in Walker over and over again. usize is simply used for output reasons, we need to know how big the new dynamic array is so that we can output it correctly.

Yeah, that's what it does all right. I still have absolutely no idea what Walker is for but getting loaded with a bunch of letters.

Try outputting Walker after each loop and see if it contains what you expect. In fact, after the first loop do you even know what should be in Walker???

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

Then regardless of whether or not the forst and second elements of the array are equal the i and j gets plus plused. I hope it makes sense.

No. All you did was say "it does 'this'". What does each and every line do and why? A comment like
Walker++; // increment Walker
is not acceptable. Why are you incrementing Walker? What's it's purpose?

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

You can't increment constant values. That's why they are const

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

Please explain this loop. It doesn't make any sense to me.

for (int i = 0; i < size; i++)
{
    for (int j = i + 1; j < size; j++)
    {
        if (array[i] != array[j])
        {
            *Walker = array [i];
            Walker++;
            usize++;
        }
        i++;
        j--;
    }
}

And please explain IN DETAIL. Don just say it does 'this'

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

1) If they give you the same value they are defined the same.
2) If they are not supposed to be the same you did something wrong that gave the same value.
3) If you load the same value into a double and a long double, why would you expect 2 different values?

In other words, given your extremely vague description, any answer is possible.

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

Include the file name.p (a text file) that's in the name directory into the code.

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

So what's not working right? How can you tell?

when asking for help, you must tell us what's going on, not just say "it doesn't work". There are hundreds of ways it can fail. Which one is yours?

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

Line 74 is an open brace in void mainscreen().

You obviously haven't learned how to format your code yet. Please take a look at this and format your code properly so it can be followed. Many errors can be found in seconds with properly formatted code.

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

Every time you go throught the loop when k equals i-1 you have a match.
Start the i loop at k+1 and get rid of the +1 elsewhere in that section.

Also, the standard way to do loops is
if you defined the array as A[20], your loop is set up as:
for (i=0; i<20; i++)

It gets very confusing if you mix <= and => and +1s and all that stuff.

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

The error kicks the user out of the program so it shouldn't display any results.

OK, I get it now... Wouldn't it be better to ask for the input again rather than waste all the previous inputs?

I think I could either subtract each denomination as many times as i can as long as it doesn't go below 0. This could probably be made into a for loop.

Or maybe I could somehow use a Token? I'm not too familiar with making a class.

Modify your program to ask for an integer dollar amount and make
change.

Or,

as long as the current total is > than the denomination
    add 1 to count
    subtract denomination from total

next denomination

By the way, if you are going to output the quantity immediately, there is no need for the array. Just sayin'.

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

No. They are just a different way of doing it. And you'd still need a loop anyway. IMO, your technique is just fine without the class. Although, if you notice, every one of your input sections look exactly the same:

cout << "Enter the number of XXX Dollar Bills you have: ";
cin >> bill;
cout << '\n';
bills.push_back(bill);
if (bill<0)
    error("You can't have a negative value.\n");

except for the XXX value. You could use a single loop with the XXX values in an array.

Also note that if you enter a negative number, you
1) display an error message but do not ask for a valid value
2) store and use the negative number anyway

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

format your code better. It very difficult to follow.

How do I link the names inputed together with the height and width???

Well, if you need to swap the name[i] with name[j], what else do you need to do?

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

Line 38 you probably want diff_w and suitor_w

Sort on the value you want (diff_w or diff_h). Make sure you swap all the arrays. Then output your data for that sort.

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

If you aren't sure how find works, you should forget all the other parts of the program for the moment and just program various uses of find until you understand how that works. That will make programming the rest of the task easier.

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

Because if you deleted the post, wouldn't all the replies look a little stupid? ;-)

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

whats wrong with it?

See this

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

And what happens?

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

1) void main() is wrong. See this
2) conio.h is non-standard. You do not need it.
3) format your code properly.

i'm thinking of using an array...the code ive done would read the first line right?

Right.

but i want to read as an array if it would be possible..

It's completely possible.

I got an error when trying it.

trying what? Reading into an array? Since you don't have any arrays and you are reading only one line, you can't have an error reading an array. So we can't help you figure out what you did wrong.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
nitin1 commented: walt will always be walt ;) he can never change :-D +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

nitin1 is correct.

With a little more detail:

Any number that starts with a zero is interpreted in base 8 (octal) rather than base 10 (decimal). Therefore your 011 is: one 8 and one 1 rather than one 10 and one 1.

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

If you want to ask a new question, there are two things you need to understand:

1: Make a new article

Don't just add to a totally unrelated article, even if it's your own.

2: Study this:

You obviously didn't understand the first time, so here it is spelled out in detail (#9 is especially pertinant in your case):

[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 you missed:

  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.
  2. Post your code. If we don't know what you did, how can we possibly help?
    -Use PROPER FORMATTING -- 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.
  3. Explain what the code is supposed to do. If we don't know where the target is, how can we help you hit it?
  4. Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My question at this moment, two+ hours later is: "did you
1) wait two hours for an answer and do nothing?"
2) try your idea to see if it worked so you'd know if it works?"

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

That completely depends on what you are trying to do there. You are asking for 2 types of functionality:
1) enter letters and use them as is
2) enter numbers and convert them to binary

Which do you want? What if you want to enter the character '6'? You can't do it. Your code only handles the number 6.

Think about it...

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

Doesn't work means that my function is not working the way I want it to.

Then, with that detailed information, the answer is "then you did something wrong and have to figure out what it is". If you took your car to get fixed and gave them that explanation, what do you think they'd say?

I have a question to ask you WaltP, can I use award_amount in my getScholarship_Money function after I get the result of award_amount? (As long as I call getAwardAmount() before the getScholarship_Money function?

Now that is a question we can answer. Yes.

You can pass function2() into function1() as a parameter, but in function1() it's just a variable name. Not a function.

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

You've pretty much got it...

The explanation I was looking for you stepped around rather than stating directly (understandably).

When you put a char into an int (or int into double, char into double, etc) the compiler does a translation to 'make it fit'. That's also true when calling or returning from a function.
It's safe up to a point. If you put an int 130 into a char, you will lose some of the number. That's what you have to be careful about.

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

i think im getting it now :) thanks for pointing it out :)

Looks like you are...

the char byte gets copied into the lowest byte of int.
....
(0--0)(0--0)(0--0)(10000001)

Good...

i dont think an integer can give 'A' output to the console... although data stored is the same...

Try it... Define a char and and int. Load 65 into both. Now output both. What happens? Why?

did i make sense?

You're doing good :)

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

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

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

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

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

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

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

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

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

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

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