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

Sit down at your desk and execute your code with paper and pencil. Be careful not to 'fix' the program in your head because you know what it should do. Do exactly what the code tells you to do.

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

And yes, I do know the maximum size of values on a line, it shouldn't be over 25.

However, I'm still not sure how I would go about implementing your idea given this knowledge, could you give me a tip? Thanks.

Well, since you said

Pretend each line that starts with f only had 3 numbers per line,

maybe pretend they have 25.

t_man700 commented: Very helpful in answering my questions! +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We need a DaniWeb mascot that we can use in pictures like that,

How about these (third one's just for fun)

Dani commented: Haha love it +0
jonsca commented: Didn't you guys go to high school together? ;) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hmmm...

Nick Evan commented: Ha! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Just call the function. There's no magic about it at all.

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

I'd be willing to help if I could read your code. You need to format it so all of us can see what you are doing -- including you.

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

The only thing I did not see in this thread is:
Use the difftime() function check the time difference.


But what I do see is a lot of help given and no attempt, only attitude, from the person asking for help. Please reread this thread and try using the help given.

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

Why?

Since I'm not a Facebookie not a Tweetie, I'm honestly curious as to why all this linking is a good thing. What does it really do for a member? for DaniWeb?

jonsca commented: I know it's that you just don't want people to see your pictures of you partying in the club. Personally, I'm trying to hide my faux celebrity status. +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That's pretty much it, except
1) main() is an int, so always use int main() .
2) Watch your formatting. Be consistent.
This section

while ( i <= num )                  // factorial 
     {
           result *= i ;
           i++ ;
           }
         
         cout << num << " ! = " << result ;
         cin.get () ;
}

should be

while ( i <= num )                  // factorial 
    {
         result *= i ;
         i++ ;
    }
         
    cout << num << " ! = " << result ;
    cin.get () ;
}

You are using SPACEs to indent -- excellent!! Switch to 4 though, not 5.

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

Peeps? :icon_rolleyes:

Try This and This

anirudh33 commented: the perfect answer +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You are making it hard on yourself. The board should be 4x4 because those are the playing positions. On output you should add the borders. That would alleviate all the checking to see if you are going to trash a border or not.

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

Hey everyone :) Hope you can help

Here is what I've done with the instructions given:

I need to know the average price difference between the cash and credit prices. But i'm pretty sure that only comes in at the end. Here is what my this function is supposed to do:
determine the difference between the cash price and credit price for an item and add this difference to the total of the differences. So what I've done below seems pretty basic to me- but I'm guessing this must be the error based on what I try to do with the code later on.]

Yes it seems pretty basic.
I suppose it could be the error, if we had a clue what the error is. Without explanation of any kind, I can see either no error, or a possible error. But I'm only guessing.

When asking for help, assume we know nothing about your code, and your thoughts on the program. You need to explain in detail what you are trying to accomplish, and what leads you to believe there's an error.

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

Yes.

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

Draw data out on paper. 1 dimension is a row. 2 dimensions is row and col. Try loading a string into it and see what happens.


If you don't understand something, draw a picture.

AndreRet commented: Thanks for the rep today.:) +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

By the way, isalpha() only checks for Letters, isalnum() checks for Letters and Digits..

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

When you make a post and it looks bad, click the EDIT button to the left and fix it!

kvprajapati commented: :) +12
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I think that a carat is a good idea.

Of course you would, you're a girl. Especially if it had 23 friends. :D

Me, I'd like a carrot.

jonsca commented: Someone had to say it!! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Thank you fbody but i still can't see a rule resembling this restriction.It is addressed to those who post vague questions and ask for code without providing evidence of trying.Well this didn't happen in my posts but at the time when i first started posting .. i admit i didn't read the rules right away but now i was actually trying to abide them.What?Oh .. and where did you see Waltp.. frowns on stackoverflow.com where everybody is posting relevant pieces of code to actually help each other and not vague phrases lile "do this .. do that .. erm .. no no no try that instead".From your private message i understand this is your forum and your site i can play by your own rules which stem from your state of being .. (not being written anywhere) or "provide my great knowledge elsewhere".Is that really the politics on daniweb?Cause if so .. i will just delete my account (not sure if i'm allowed though)

Ahh, so now we're down to personal attacks, even though I've down-repped you once and others have been down-repping you since you started.

Read cscgal's statement again "please don't expect quick solutions to your homework." Read between the lines. Use the logic necessary in programming for more than programming. What's that statement say from the helping side of the post? Isn't posting full working code a quick solution? N'est-ce pas?

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

Or add another value called HighCard. For a pair, set HighCard to the value of the pair (4 for Fours, 11 for Jacks).

This would be helpful for Pairs, Trips, Straights, etc.

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

Where did you learn that if(menuinput == (l || L)) is a valid IF statement? You need to look up how a compound statement is written.

And what's the purpose of assigning l = 'l'; and L = 'L'; just to use variables in the IF statement? Use the characters themselves.

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

You really want us to look through 650 lines of code to
1) find you compare function?
2) figure out what's wrong?

Sorry, nope. Pinpoint the problem areas and we can see what we can find.

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

Also, visiting threads does not set the icons to READ.

Dani commented: Thanks for the find +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Now clicking on the thread icons no longer goes to the unread posts. Even after ^R.

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

Yes, easiest is to open the file for read and check for an error.

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

In Explorer:
Right click on the file containing the code
Choose DELETE.

jonsca commented: I tried that with My Computer/C: drive and now my computer doesn't work ;) +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

the line

free y

cause problems.

After 30+ posts you should know better by now.
Ground it for a month with no TV.

should i use it after

return y

If you use it after return y will it be executed? What does return y do?

[EDIT]
I see this question has already been answered here. You didn't believe him?
[/EDIT]

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

THanks Waltp i was just writing peace of the code not all of it. But Arbus answer was really helpful and thats the exact thing i wanted

Maybe so, but what I wrote was something you needed. There's a difference.

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

It isn't possible with Standard C. You have to learn special function added by the compiler authors for your specific compiler and operating system.

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

This is my computer science project,we were told to make any software we wish to make,so I thought about making a calculator,below is the code,but it doesn't seem to be functioning well,could anyone help and tell me what went wrong(I am using borland cpp 4.5 compiler,this program uses getch() to read the keystrokes)

1) In English, there is always a SPACE after punctuation
2) As for it not functioning well, try unplugging the computer from the wall socket, then the lights won't go out when you run the program

Now I admit I'm guessing on #2 what "doesn't work well" means since you didn't bother to tell us. If I'm wrong, try explaining the problem.

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

Good answer. I saw shuffle in the STL docs. I'll google it. Thanks for all the help.

Shuffle the deck yourself, don't use STL to do it for you. You won't always have STL so you'll need to know how to do it by hand.

jonsca commented: I always print out the deck on paper, shuffle it by hand, then I key back in the values. +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Of course, iwould not modify it. But to give suggestion i would need to the code.

e.g. whether OP has use fprintf or fwrite...........depending on it I would suggest fsanf or fread

Stop responding to posts just to respond. I did not quote you, therefore I was not talking to you.

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

Good. Now try
AA
ABCCBA
ABCDEEDCBA

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

Where you got the idea ^ means raised to the power in C is a great question.

Belaying that, look in the math.h header for the function pow()

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

now what do you think is wrong with my new code???

As always, you aren't using CODE Tags.

Also, give a detailed description of what is happening wrong. Each time you post, explain! With CODE TAGS!

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

Here. Stop being so lazy.

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

It's not impossible. By C++ native I mean other headers it comes with when you download an IDE and NOT just the input and output stream. Don't tell me it's impossible and lie to me; it's not.

OK. You obviously know more than I do. I've only been programming for 30 years and must not know enough yet. And since I'm wrong, tell me how you can do it...

And I have not a clue on what I can do that's lesser than a snake game, but larger than any one input output program. Plus, how could I work my way up to a snake game if I don't even know where to start?

I'm not exactly following a road here.....

Then buy or download a book or follow a tutorial. You can't just do neurosurgery without learning how to use a scalpel first.

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

Change char det = *test; to char *det = test;

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

I did this....simple but works

int main()
{
  char c1, c2;
  c1 = getchar(); // get first input
  c2 = getchar(); // get second input
  if (c1 == '\n' && c2 == '\n') // if post inputs are enter
     exit(1); // exit
}

So what happens if someone types in " [ENTER][ENTER]"?

Put each getchar() in a loop testing for '\n': while (getchar() != '\n');

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

Question 1.will cin.getline()only stream in 1 line, instead of cin >> file, and if so,how do you go about this with alphabetizing.. What I am thinking is: cin.getline() will stream in 1 line, maybe at a time, and then you can call the swapNames function after the first cin.getline(), and if that second line's first int is smaller than the first lines, switch the second line to the first.

How about read in each line and sort the lines using the bubble sort. You already suggested it.

Question 2. How do i go about converting the char array that has the text file in it, into integers. I've never had to do this, and I've heard it makes the process easier using int.

Good question. What integer would you convert "Jones, Frederick M" into?

And stop thinking in terms of character arrays. You already posted that you should "use the C++ string class." That solves all of your questions in one C++ type.

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

i agree i've been looking at it and i'll try and figure it out, but would you guys mind helping me this has been stumping me the past 2 days.

Yes, if you will format the code. If it's true that this is the format your instructor is teaching, please change instructors. He is not a programmer. Sorry.

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

I repeat:

You are using the size of full to test characters in temp. Are you sure temp has >= characters than full? Display the values and see.

lexusdominus commented: a minimal amount of information solving a massive problem +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

okay but not only do i need a portable substitute for system("cls"),

No you don't. There is no reason for a console program to clear the screen. It's actually annoying to the user.


And this was mentioned a couple times, just not strong enough for you to hear it, so I'll try:

Never, NEVER, NEVER call main() ! NEVER! It is not a function per se/ It is the entry point to your program from the O/S. If you need to start the program over, use a loop.

And get rid of conio.h . It's not standard and you don't need anything from it.

Lastly, what do you need windows.h for? What are you using from it? Whatever it is, you probably shouldn't be using it, either.


PS -- true to form when someone says my problem is easy, it becomes a mega-thread. The word easy is the forum equivalent of radiation on the animal kingdom that creates monsters. And saying incredibly is just turning up the Roentgens! Easy my butt... :icon_twisted:

jonsca commented: Thank you. +6
NP-complete commented: wondering the same while flipping the pages...:) +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So with your new and improved code, how do you pass the integer back to main() ? I think jonsca's idea is best.

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

The logic is slightly off.

If we click the UP or DOWN, the vote is automatically counted. Then a box pops up with two buttons,
1) Vote
2) Leave message and vote
The box also has the standard corner X to dismiss the box.

The vote should only be taken when one of the two buttons are clicked. If the X is clicked, no vote should occur.

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

You need to read the input as a character string. Then look at the string and make sure every character is a digit. If so, convert to integer, if not display an error.

L3gacy commented: thanks +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes, %c should be used instead of %s. This isn't technically a C-string, just a simple array. A string would require 7 spaces, to accommodate for the NULL value at the end.

No, technically it is a C-string. It has quotes which by definition ends in a NULL value. The definition actually overflows the array.

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

I have a question about:
infile >> names >> grade ;

Will this go through the first line of the file and put the name in names[] and the gpa in grade[], then repeat with i++?

What happened when you tried it? That's easier and faster than posting on a forum.

After this part, I need to order the array so that it is in ascending order, meaning that the lowest gpa goes first with the correct name, followed by the 2nd lowest gpa with the correct name, ect.

That's called a sort. You won't confuse us by using the proper terms.

I have to swap gpa[0] and gpa[2], which means doing the same thing to names[0] and names [2]. How do I make a swap?

By swapping both gpa and names when the gpa is in the wrong order.

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

Please help and before you post telling me to us "cout<<" and all of the things related to iostream or whatnot im not able to because of the older versions of c++ we use.

Then you are writing C, not C++. There is no C++ compiler that cannot use cout . It's part of the language.

And if you aren't allowed to use "iostream or whatnot", why are you including it?

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

Always nice to save a line of code!

Not always -- not if it makes the code harder to read.

for(unsigned j = 0; j < 256; j++)
    argument[j] = '\0';

is far superior to

memset(argument,'\0',256);

The former shows exactly what's going on in the context of the program.

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

Use CODE Tags -- they are described all over this site. Including on the background of the box in which you typed your question.

Please read the following information:
formatting
void main()
pausing a program