hehehe how is this

This is a discussion on hehehe how is this within the C++ Programming forums, part of the General Programming Boards category; #include <iostream> using namespace std; #include <windows.h> int alpha[26]; char alpha[26]="abcdefghijklmnopqrstuvwxyz"; char phrase[50]; int main() { cout<<"Welcome To My Morse ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    51

    hehehe how is this

    #include <iostream>
    using namespace std;
    #include <windows.h>



    int alpha[26];
    char alpha[26]="abcdefghijklmnopqrstuvwxyz";
    char phrase[50];

    int main()
    {
    cout<<"Welcome To My Morse Code Converter!\n";

    cout<<"enter a phrase for conversion in lowercase letters\n";
    cin>>phrase[];
    for (int i = 0; i <50; i++)

    switch(phrase[i])
    {

    case:'a'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";

    case:'b'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    cout<<"/a";
    cout<<"/a";

    case:'c'
    cout<<"/a"
    Sleep(100);
    cout<<"/a";
    cout<<"/a";
    Sleep(100);

    case:'d'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    cout<<"/a";


    case:'e'
    cout<<"/a";

    case:'f'
    cout<<"/a";
    cout<<"/a";
    Sleep(100);
    cout<<"/a";


    case:'g'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);
    cout<<"/a";


    case:'h'
    cout<<"/a";
    cout<<"/a";
    cout<<"/a";
    cout<<"/a";



    case:'i'
    cout<<"/a";
    cout<<"/a";


    case:'j'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);
    cout<<"/a";

    case:'k'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    cout<<"/a";
    Sleep(100);


    case:'l'
    cout<<"/a";
    Sleep(100)
    cout<<"/a";
    cout<<"/a";


    case:'m'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);


    case:'n'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";


    case:'o'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);


    case:'p'
    cout<<"/a";
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);
    cout<<"/a";

    case:'q'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);
    cout<<"a";
    cout<<"/a";
    Sleep(100);

    case:'r'
    cout<<"/a";
    cout<<"/a";
    Sleep(100);
    cout<<"/a";

    case:'s'
    cout<<"/a";
    cout<<"/a";
    cout<<"/a";


    case:'t'
    cout<<"/a";
    Sleep(100);


    case:'u'
    cout<<"/a";
    cout<<"/a";
    cout<<"/a";
    Sleep(100);


    case:'v'
    cout<<"/a";
    cout<<"/a";
    cout<<"/a";
    cout<"/a";
    Sleep(100);


    case:'w'
    cout<<"/a";
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);

    case:'x'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    cout<<"/a";
    cout<<"/a";
    Sleep(100);

    case:'y'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    Sleep(100);

    case:'z'
    cout<<"/a";
    Sleep(100);
    cout<<"/a";
    cout<<"/a";

    }

    return 0;
    }

  2. #2
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801
    Whats up? I assume it won't work and that's why you are posting, though you didn't say.

    Anyway, you need parentheses for your 'for' loop

    Code:
    cout<<"enter a phrase for conversion in lowercase letters\n";
    cin>>phrase[];
    for (int i = 0; i <50; i++)
    {
    //enormous switch statement
    }
    Been a while since I worked with strings but I don't think you can do this:

    cin>>phrase[];

    but there is a good chance that I am wrong, can someone verify please? Thanks.

    And you are better off doing:

    Code:
    for (int i = 0; phrase[i] != '\0'; i++)
    Last edited by minesweeper; 01-14-2003 at 01:05 PM.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    This works, but it's awful. Try using a lookip table and translation function instead of such a big switch statement. There were tons of syntax errors, I have to assume that the little "hehehe" at the beginning of your topic means that this program is a joke on anyone who bothers to get it working.
    Code:
    #include <iostream>
    using namespace std;
    #include <windows.h>
    
    char alpha[27]="abcdefghijklmnopqrstuvwxyz";
    char phrase[50];
    
    int main()
    {
      cout<<"Welcome To My Morse Code Converter!\n";
      
      cout<<"enter a phrase for conversion in lowercase letters\n";
      cin>>phrase;
    
      for (int i = 0; i <50; i++)
      {
        switch(phrase[i])
        {
        case'a':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          break;
          
        case'b':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          break;
          
        case'c':
          cout<<"\a";
            Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          break;
          
        case'd':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          break;
          
          
        case'e':
          cout<<"\a";
          break;
          
        case'f':
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          break;
          
          
        case'g':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          break;
          
          
        case'h':
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          break;
          
          
          
        case'i':
          cout<<"\a";
          cout<<"\a";
          break;
          
        case'j':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          break;
        case'k':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          break;
          
        case'l':
          cout<<"\a";
          Sleep(1000);
            cout<<"\a";
          cout<<"\a";
          break;
          
        case'm':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          break;
          
        case'n':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          break;
          
        case'o':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          break;
          
        case'p':
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          break;
        case'q':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          cout<<"a";
          cout<<"\a";
          Sleep(1000);
          break;
        case'r':
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          break;
        case's':
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          break;
          
        case't':
          cout<<"\a";
          Sleep(1000);
          break;
          
        case'u':
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          break;
          
        case'v':
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          break;
          
        case'w':
          cout<<"\a";
          cout<<"\a";
          Sleep(100);
          cout<<"\a";
          Sleep(1000);
          break;
        case'x':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          break;
        case'y':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          Sleep(1000);
          break;
        case'z':
          cout<<"\a";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          break;
        }
      }
      return 0;
    }
    *Cela*

  5. #5
    tetra
    Guest
    here i fixed it thankyou so much for everything! this actually prints out morse code!
    Code:
    #include <iostream>
    using namespace std;
    #include <windows.h>
    
    char alpha[27]="abcdefghijklmnopqrstuvwxyz";
    char phrase[50];
    
    int main()
    {
      cout<<"Welcome To My Morse Code Converter!\n";
      
      cout<<"enter a phrase for conversion in lowercase letters\n";
      cin>>phrase;
    
      for (int i = 0; i <50; i++)
      {
        switch(phrase[i])
        {
        case'a':
          cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          break;
          
        case'b':
          cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          break;
          
        case'c':
           cout<<"\a*-*";
            Sleep(1000);
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(1000);
          break;
          
        case'd':
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          break;
          
          
        case'e':
          cout<<"\a";
          break;
          
        case'f':
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          break;
          
          
        case'g':
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          break;
          
          
        case'h':
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          break;
          
          
          
        case'i':
          cout<<"\a";
          cout<<"\a";
          break;
          
        case'j':
         cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          break;
        case'k':
          cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a*-*";
          Sleep(1000);
          break;
          
        case'l':
          cout<<"\a*-*";
          Sleep(1000);
            cout<<"\a";
          cout<<"\a";
          break;
          
        case'm':
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
          break;
          
        case'n':
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          break;
          
        case'o':
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
          break;
          
        case'p':
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          break;
        case'q':
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"a";
           cout<<"\a*-*";
          Sleep(1000);
          break;
        case'r':
          cout<<"\a";
          cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          break;
        case's':
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
          break;
          
        case't':
           cout<<"\a*-*";
          Sleep(1000);
          break;
          
        case'u':
          cout<<"\a";
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(1000);
          break;
          
        case'v':
          cout<<"\a";
          cout<<"\a";
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(1000);
          break;
          
        case'w':
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(100);
           cout<<"\a*-*";
          Sleep(1000);
          break;
        case'x':
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(1000);
          break;
        case'y':
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
           cout<<"\a*-*";
          Sleep(1000);
           cout<<"\a*-*";
          Sleep(1000);
          break;
        case'z':
           cout<<"\a*-*";
          Sleep(1000);
          cout<<"\a";
          cout<<"\a";
          break;
        }
      }
      return 0;
    }

  6. #6
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Damn, it's horrible to run this program!
    But anyways it's a nice idea
    none...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. hehehe
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-31-2006, 07:05 AM
  2. hehehe cry babies
    By InvariantLoop in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-27-2004, 08:23 AM
  3. Sockets, Winsock
    By mattbbx in forum Networking/Device Communication
    Replies: 4
    Last Post: 08-21-2003, 05:09 PM
  4. Here it is: Xtreme Fight 1.0 !
    By funkydude9 in forum Game Programming
    Replies: 13
    Last Post: 11-22-2002, 07:40 PM
  5. Moderators?
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 30
    Last Post: 08-10-2001, 02:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21