I had issues with CMD before, so I guess I have the same problem now!
Do you have any suggestions how I can comment the text?
What is important and what's not?
I think the program should start over after you are finished, but my doesnt.
I looks like this: "Home team won over guest team with 2-3Press key to continue"
and when you press a key the program shuts down!

My next assignment is to let an user to write in ordinary text or morse code, and the user can choose if he/she wants to translate it!
Example:
Welcome!
1. Translate from morse
2. Translate to morse

Do you have any tips for me?
Should I use case, switch and so on...

How do I write to be able to write in swedish with å ä ö?
I imported "iodos.h"
and added dos_console(); to main, but it doesnt respond!

>I had issues with CMD before, so I guess I have the same problem now!
Do you have any suggestions how I can comment the text?

What do you mean by: how can I comment the text?

  • Do you want to write the program's output to a file?
    In that case you might want to run your program from the command line, like this:
    [I]yourprogram[/I] > output.txt (The output of your program will then be written to a file on your harddisk called 'output.txt')
  • Or do you mean that the Command Window pops up, and after entering the information disappears directly?
    (if this is the inconvenience then you might want to add [B]cin.get();[/B] before return 0; if there's one or in case there isn't a return 0; statement just put it on the latest line of your main function...
  • Or do you mean how to add comments to your code?
    In that case you might want to do like this: /* this is a comment */ for C-style comments (these can be spread amongst multiple lines), or // this is also a comment for single line (C++) comments...

>What is important and what's not?
What do you mean? Can you clarify this question?

>I looks like this: "Home team won over guest team with 2-3Press key to continue"
and when you press a key the program shuts down!

Do you want that the "Press any key to continue" message appears on another line? (it probably appears because you're using an IDE)
You could add a cout << endl; on the line before your program stops executing...

>My next assignment is...
>Do you have any tips for me?
Yes, take a look at the link in my previous post :)

Hope this helps!

Thank you for your help! Your tips improved my knowledge extremly!
People have been so rude to me before you helped me!

Here. I have made revisions to your code that you can use to compare to your old code to see what you did wrong. Also I corrected some spacing errors and punctuation errors. I also through a system pause in at the end to pause the program.

#include <iostream>
#include <string>

 using namespace std;
  int main()
 {

	 string home, guest;
     int hnr, bnr;

	 cout << "Title" << endl;
	 cout << "----------------" << endl;

	 cout << "Write name of home team: "; 
     cin >> home;
	 cout << "How many goals did " + home << " get? "; 
     cin >> hnr;

	 cout << "Write name of guest team: "; 
     cin >> guest;
	 cout << "How many goals did " + guest << " get? "; 
     cin >> bnr;

	 if (hnr > bnr)
	 {
		 cout << home << " won against " << guest << ". The result was " << hnr << "-" << bnr << ".";
	 }
     if (hnr < bnr)
	 {	
		cout << guest << " guest won over " << home << ". Final result was " << hnr << "-" << bnr << ".";
	 }
     if (hnr == bnr)
     {
             cout << "Tie between " << home << " and " << guest << ". The match ended with " << hnr << "-" << bnr << ".\n";
     }
	 system("pause");
	 return 0;
  }

OK man i fixed all your bugs and cleaned it a bit...
u also might want to pick different variable names so its easier to understand...

#include <iostream>
#include <string>
using namespace std;
  
int main()
{

string home, guest;
int hnr, bnr;

cout << "Title" << endl;
cout << "\n----------------" << endl;

cout << "Write name of home team: "; cin >> home;
 cout << "How many goals did home team make? "; cin >> hnr;

cout << "Write name of guest team: "; cin >> guest;
cout << "How many goals did guest team make? "; cin >> bnr;

	 if (hnr > bnr)
	 {
		 cout << home << " won against " << guest<<".\n";
         cout << "The result was " << hnr << "-" << bnr;
	 }
	 else if (hnr < bnr)
	 {	
		cout << guest << " guest won over " << home << ".\n"; 
        cout <<"Final result " << hnr << "-" << bnr;
	 }
	 else if(hnr == bnr)
	 {	
		 cout << "\nTie between " << home << " and " << guest << ". The match ended with " 
			  << hnr << "-" << bnr;
	 }
return 0;
}

hey. i was looking at your scipt for the program, and i well i didnt know about the system("pause").. thanks

Did someone actually notice that the OP's problem was already solved in this post ??

This would do it...

#include <iostream>
#include <string>

 using namespace std;
  int main()
 {
      char Team1[40];
      char Team2[40];
      int score1;
      int score2;
      
      cout << "enter the name of the two teams" << endl;
      cout << "Home Team: ";
      cin >> Team1;
      cout << "\nGuest Team: ";
      cin >> Team2;
      cout << "Enter scores (Home team Guest team): " << endl;;
      cin >> score1;
      cin >> score2;
      if(score1 < score2) {
                cout << "Guest" << Team2 << " won" << endl;
      }
      if(score1 > score2) {
                cout << "Home team "<< Team1 << " won" << endl;
      } if(score1 == score2){
             cout << "It was a tie" << endl;
             }
      system("pause");
      return 0;
}

This would do it...

#include <iostream>
#include <string>

 using namespace std;
  int main()
 {
      char Team1[40];
      char Team2[40];
      int score1;
      int score2;
      
      cout << "enter the name of the two teams" << endl;
      cout << "Home Team: ";
      cin >> Team1;
      cout << "\nGuest Team: ";
      cin >> Team2;
      cout << "Enter scores (Home team Guest team): " << endl;;
      cin >> score1;
      cin >> score2;
      if(score1 < score2) {
                cout << "Guest" << Team2 << " won" << endl;
      }
      if(score1 > score2) {
                cout << "Home team "<< Team1 << " won" << endl;
      } if(score1 == score2){
             cout << "It was a tie" << endl;
             }
      system("pause");
      return 0;
}

To kangarooblood:
Do you want me to become angry :angry: ?
You MUST read the forum rules first (We don't give away free code here!!)
Before replying to a thread: read the whole thread, in that case you would have seen that this problem is already solved!
As mentioned in this post (of this thread) and in this post of a recent thread started by you: Don't use [B]system("pause");[/B] , but what do you do? You still continue using it, you even don't read your threads careful! :(

Sorry, it's a habit to use system("pause"); I'm trying to get used to not do, i did it in my last update of my tic tac toe instead of system("pause"); I used cin.get() and I promise to not give away any more codes and I promise to read the whole thread more carefully, I didn't see it was more then one page.


I feel :$ ...

BTW, why don't we give away free code, just curious?

>BTW, why don't we give away free code, just curious?
How do you think that someone can become a programmer if he even doesn't write code himself?

Did someone actually notice that the OP's problem was already solved in this post ??

You're right, Tux. The OP appears to be gone.

Well maybe you could learn the code, when you see it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.