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

Are you telling me in all your schooling you've never added a bunch of numbers and calculated an average? I don't believe you. I'm sure you can easily do this on paper. (*hint*)

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

Depends on your point of view.

1) If you are into the coding and testing phase, yes. But don't you have to do math with the data read? Shouldn't they be numbers, not strings?
2) If you followed my advice, you'd still be designing, so you took shortcuts and went right to code.

Don't get me wrong, it can work this way too, but you need to
1) design a small section
2) code that section
3) test that section until it works
4) return to 1 for the next small piece...

The key word is design.

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

Hello,

I'm developing an application that reads a text file, and then replaces what's in the text file with an array (alphabet) It all works ok until I try and change the position of the inputted character and it returns:

Segmentation fault: 11 It's really confusing!

So is your description!
You want to
1) read a file
2) replace the contents with the alphabet
3) change the position of inputted characters?
Can you try to explain better what you need? What's the assignment? What are you trying to accomplish?

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

1) get rid of conio.h
2) "Write a C++ program that reads a series of 12 temperatures (floating-point numbers)" -- does your code read?
3) you obviously haven't been taught yet how to format your code -- learn this quickly and well.
4) get away from the computer.

  1. Sit down with pencil and paper and go though your simple assignment and plan out what needs to be done. Step by step.
  2. When you get the step by step done, look at each step and break it down into smaller pieces.
  3. When you can't break it down any farther, write down 12 numbers -- this becomes your 'file' (make the numbers simple.
  4. Now, starting at the top of your steps, follow them.
  5. Do exactly what the step says to do. Do not do what you meant the step to do. If you need to do that, fix the step.
  6. When you can run through all the steps correctly and get the right answer, you are now ready to program.
  7. Convert all the steps into code.
  8. Now, run through the code line by line, just like the steps.
  9. When that works, go back to the computer and start programming.

Yes, this sounds like a pain. But this is programming. It's design and planning. You can't program what you haven't planned out -- you get a jumbled mess that doesn't work.

In your case, you don't know what to do. But the description …

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

... here's how i've started out so far...

#include <iostream>
#include <fstream>
#include <conio.h>
#include <cmath>
using namespace std;
#define in_file "temp.txt" 
int main ()
{

I assume you can tell you have done nothing.

Start with opening the file (check for errors)
Use a loop to read the values and display them.

That's the first step.

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

Basically i have a cin for choosePositionX and cin for choosePositionO. If the user cin for choosePositionX and the if statement is true it runs the code in it. When the user cin for choosePositionO and the if statement is true it runs for the code for it. BUT in the event for those ifs choosePositionx and choosePositionO if its not equal then it should go to else and say this player blah blah already made this move. BUT my code ends up outputting both elses so it says it for both X and O.


The problem lays in the void makeMove() function

I did not ask for a verbal explanation of what the code does. I can see that for myself.

Reread my last post, do what's suggested, and study the values. See what those values do in your function.

If your function is correct but the values are bad, you need to find out where the bad values get into the variables. More output statements.

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

I highly recommend you change your admin password
1) Everyone uses admin
2) posting it here lets everyone else know it, too

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

[boilerplate_help_info]

Posing 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.
[*]To [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

What are the values of choosePositionX choosePositionO ticTacBoard[choosePositionX - 1 ticTacBoard[choosePositionO - 1 ?
That will tell you exactly why the IF is doing what it's doing.

Put output statements at key places in the code to see if the values are as expected. You will also be able to see why your IFs aren't doing what they are supposed to.

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

What are you yelling about? That statement makes no sense at all! I though you were a native English speaker.

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

Instead of if (choosePositionO) us else instead.

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

If he's having trouble reading a file and looking at the words, and won't post code
1) what makes you think he's been taught vectors?
2) why are you the one posting code?
3) why are you doing his homework for him?
4) why are you using a bad form for your loop counter that is a logic error?

All in all, two very bad posts.

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

Im not sure, is it correct? can you tell me how else i could do this without putting the if quit==y inside the loop, because its kind of annoying having it inside the loop

What happened when you just erased the IF block as a test?

2)Think deeper....
Ok so i put this in,

case 3:                                           //division
            answer = number1 / number2;
            symbol = "/";
            if (number2==0){
                cout << "Cannot divide by 0" << endl;
                answer = 0;
            }
            break;

Let's see.
Do the divide.
Then test if you can't do the divide.
Something seems backwards to me.

3)Look up functions and the complete syntax. Put the variables in main() k il try that

Good

4)You are using an IF anyway. It's implied in the DO-WHILE. And you are already putting a value into a global. Just move the variable into the function and return it instead.
I dont really get what you mean by this, can you give an example or post how it should be if you have time, it would really help.

When you read up on functions you will understand.

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

Have you changed your code?
If yes, do we know what it looks like now?
If no, can we really make any suggestions?
Think about it.

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

[boilerplate_help_info]

Posing 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.
[*]To [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

It's not jumping out at me (although I have my suspicions). What I'd do is
1) change the outputs from Fout into cout so you can actually watch the program as it executes.
2) add more cout statements and display values as they are read and calculated. See if the values are correct as the program progresses.

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

And what is your problem now? And please fix your formatting for the next post. The code is very difficult to follow.

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

What happened to point 2? It specifically mentioned CODE Tags. And proper formatting. You used neither.

As for your code, so many problems!

ifstream Fin;
	ofstream Fout;

Fin>>FName;     // Where are you inputting from?
Fout<<Name;     // 1: Where are you outputting to?
                // 2: What value are you outputting?
while(!Fin.eof())
	{
		do{	
		Fin>>First_Name>>Last_Name; 
		Fout<<First_Name<<" "<<Last_Name;
		Fin>>Score;         // Are you doing anything with this score?
		}
	  while(Score !=-1) ;  // What is this DO-WHILE really doing?  Work it out.
	  Fin>>(Score);
	  Sum += Score ;
	  Test_Number++ ;
	}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Just give us something to work with. We can certainly help, if you have someplace to start from, and give us enough details.

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

A couple nitpicks:

main should almost always be declared as:

int main (int argc, char *argv[])
{
    ...
}

Not really. main should almost always be declared as int main(void) . Your version only needs to be used when you need command line parameters.

And there's almost never a reason to call it from inside itself or any other part of your program. When you absolutely need to call main() yourself, you'll know. Until then, just don't do it.

No, just don't do it. There's never a need to call main() . If you need to start from the top in main() recursively, create another function that main() calls and put all the functionality into that function.

Also, the assumption should be that exit() is called only from main() (as a replacement for a simple "return" statement). Someone reading your code should expect all function calls to return execution back to their caller, and ultimately to main(), which will call exit() or return as appropriate to end your program.

IMO, and this is just an opinion, the only time you should use exit() is when you have an error deep enough in your calling structure that getting back to main() is problematic. Like in a 4th level function that can't find a required file, and returning with an error up through the 2 other functions makes the code too messy. From main() itself, why call a function? Just return. It's simpler with fewer resources.

My 2 cents...

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

[boilerplate_help_info]

Posing 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.
[*]To [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

Hi,

i want the difference of time between clicking two buttons in a label. i tried most of the things but not working for me.

So, without knowing what most things are, all that's going to happen is you'll get the same stuff you already tried.

could anyone provide me the exact coding for this.

Where on this site have you read the announcement "Free coding solutions. Perfectly coded for your vague needs"?

There are multiple coding already there for those buttons however i want to use it to watch the break timings of the users.

Whatever that means. If you have multiple codings already, how do you know our perfect code will work well with your codings?

Please provide the exact code for this.

This would be a great help for me.

Of course it would. What do we get out of it?

Sorry, but the terms "provide exact code" and "I've tried most things" without explaining what you've tried are major red flags for us. They say you want us to do your work for you. Free. Anyone can say "I've tried".

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

Of course I can do it with PHP. But you have to have them installed on your server. Not an option.

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

So sorry the site has been down for a few hours this early morning. It happened when it was time to switch the clocks back (the servers didn't like that) ...

After 50 years you'd think someone would have figured out the DST switch by now! :icon_rolleyes:

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

They need help for their homework or project and waiting a few days is a good thing? How long would you wait when you need help with a problem? I'd expect everyone would just go somewhere else.

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

You can't

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

nono.. its not the scanf! its the getchar. just add a fflush(stdin) statement before getchar and it will work fine

nono.. fflush(stdin) is very wrong. See this

And yes, it's the scanf() causing the getchar() to not work as expected. Otherwise, why would you want to flush the buffer? :icon_rolleyes:

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

[boilerplate_help_info]

Posing 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.
[*]To [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

My questions are:

1) Why the IF statement just after the DO?

do{
        if (quit=="Y"||quit=="y"){
            return 0;
        }
        . . . 
        restart();
    }//close do
    while(quit=="N"||quit=="n");

What does it do that the DO-WHILE doesn't do?

Because the do-while only loops if quit==N so i added the if statement to also check for quit==Y otherwise it wont check for Y at all or is this not right? what else could i do?

Why should it check for Y? You checked for N and continued. So you are assuming Y. Nothing wrong with that. Assuming your DO-WHILE test is correct. Is it?

2) What happens if number2 is 0 and symbol is "/"?
It says inf, so i guess i need to write if (number2 < 1) { answer = 0; } thats right?

Think deeper....

3) Pass the values into the math function rather than use global values:

//Show math
void showMath(){
    cout << number1 << symbol << number2 << "=" << answer << endl;
}

Globals are generally considered a bad thing.
Can you help me out with this one, i dont know where else to put them because it doesnt work if they are in the showmath function.

Look up functions and the complete syntax. Put the variables in main()

4) The restart function should return a value rather than use a global. Should it return a string or a boolean?
String would be quicker otherwise i would need an if statement converting it to a boolean wouldnt …

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

Using onMouseOver in a link
- I am able to display a file's contents in a frame.
- I can display an image file in an IMG tag
But I can't figure out how to combine the two. What I want to do is onMouseOver display the contents of a text or html file in a TD element.

In essence:

<a href="#" onmouseover='document.getElementById('ingred2').[I]text[/I]="FileName.htm"'>

<TH id='ingred2'>Display-File-Contents-Here</TH>
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Never never NEVER call main() . NEVER! It's an entry point to your program not a normal function.

Why call exit() (twice) when all you need to do is return?

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

a++ and ++a alone mean the same thing. When used in an equation, they are slightly different.

Run this and figure it out:

int a,b,c;

a = 5;
b = 5;

c = a++;
cout << "c=" << c << "  a=" >> a << endl;

c = ++b;
cout << "c=" << c << "  b=" >> b << endl;

It's quite easy to design a test like this to answer questions yourself...

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

My questions are:

1) Why the IF statement just after the DO?

do{
        if (quit=="Y"||quit=="y"){
            return 0;
        }
        . . . 
        restart();
    }//close do
    while(quit=="N"||quit=="n");

What does it do that the DO-WHILE doesn't do?


2) What happens if number2 is 0 and symbol is "/"?


3) Pass the values into the math function rather than use global values:

//Show math
void showMath(){
    cout << number1 << symbol << number2 << "=" << answer << endl;
}

Globals are generally considered a bad thing.


4) The restart function should return a value rather than use a global. Should it return a string or a boolean?

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

That was not the response I was expecting, but thanks all the same. I already have the code to create the process.

So it was just a test to see if someone gave you the answer you already knew? That's not even fair... :icon_wink:

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

Sorry but everyone can count 1 to 1000 and infinity,
whats new in this?
whats interesting this thread?, in Team A & B, at least we was having two team as opponent what is going to happen just pages are going to increase and no of post will increase neither interesting nor useful thing going to happen here.

Spoilsport!

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

What is 130790?

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

How do I modify the CreateProcess function to create multiple processes and have them run at the same time?

Contact microsoft and ask them for the source code to CreateProcess so you can modify it. Of maybe you can use CreateProcess 10 times?

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

Looks OK so far.

[edit]

Sorry about that. The only thing I did wrong I suppose is proclaim how new I was. I also forgot to post what actually happened when I tried to run the program.

Proper formatting, too. But yours is better than most. :icon_wink:
[/edit]

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

OK, I see where HG is going, and I see the conundrum cwarn has. I myself have written tutorials on another site that are linked to by many people here. That seems to be OK because DW doesn't want those tutorials as they are posted elsewhere. But they seem to be useful.

But in cwarn's case, he owns the site and wrote the tutorials. Hmm... And he wants the site to be affiliated directly with DW.

Well then, Dani, check out at his site. If it meets your quality standards and the articles and tutorials in his wiki complements well what we have here, give him your blessing. If not, what does he need to do to come up to your standards?

IMO, there should be no problem with a quality site that can be used in tandem with the forums. It's just an extended community at that point... Like a cousin site so to speak :icon_wink:

cwarn23 commented: thanks for pointing that out +12
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How did you find keybd_event? Someone told you about it, I assume. Otherwise you'd know how to do your own research.

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

bump?

Do not be rude and bump threads. If someone can help they will when they get to it.
And this bump is exceptionally rude because you were asked questions and rather than answer them you just said bump? I know I would refuse to help with that attitude.

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

"Not to mention, as far as killings go, governments have pretty bad reputations in that department."

I don't think they should have these weapons of mass destruction either.

To paraphrase the bumper sticker:
If the US doesn't have these WMDs, only our enemies will have them.

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

Since Linux and Windows are two different systems, they do things differently. You're going to have to learn the Linux version of all the Windows functions you're using.

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

You do NOT need fseek() . At the beginning of the program, read the data into an array of your CURRENCY structure and you are done with the file. Then you can process all the data you want.

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

1) Did the program run correctly for all the values you tried?
2) Did you do all the points in the assignment?

If the answer is YES to both, then it's OK. If the answer is NO to either, then there's nothing for us to check, you need to check to see what you didn't do correctly.

If you need actual help with something, you have to explain in detail what you need help with.

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

I thought that only ++a would not work because it's equivalent as "a = a + 1"
while a++ would equivalent "a + 1", or what I miss?

You missed the fact that
1) a+1 simply means add 1 to a and use the result
2) a++ means a=a+1 and for subsequent uses of a use the new value.

IOW, a+1 doesn't change a whereas a++ does.

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

You need to look up the syntax for the IF statement. You have it incorrect for compound comparisons.

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

You've got it backwards.
First you design the game. All aspects of the game.
Then you break the functions of the game into smaller and smaller sub-functions.
When you get the game into the smallest pieces you then design the code using pseudo-code.
Only then do you start programming in whatever language you choose.

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

OK. As I said, understanding is the only path to programming (sounds like a Chinese proverb).

If you really need to ask, you don't understand the problem. I'm going to assume you really know the answer and I'm going to ask you this instead:

Why should the function be called in the second loop rather than somewhere else?
Where would that somewhere else be that makes sense and why?

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

You have the same print statement with only a minor change 4 times in your code. Try to figure out how to remove those 4 statements and add only 1 to print any of the 4 answers.