Thread: Need help

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    61

    Need help

    Whats wrong with this?

    Code:
    /*****************************/
    /*        Program v1.0       */
    /*****************************/
    /*      Written by Brian     */
    /*  [email protected]  */
    /*   http://ctte.php0h.com   */
    /*****************************/
    /*        Program.cpp        */
    /*****************************/
    
    #include <windows.h>
    #include <iostream>
    
    char YourName[] = "";
    char EyeColor[] = "";
    char EyeOne[] = "Brown";
    
    using namespace std;
    
    void main(){
    	cout << "Your name: " << endl;
    	cin >> YourName;
    	cout << "Eye color: " << endl;
    	cin >> EyeColor;
    	if(EyeColor == EyeOne){
    		cout << "beatiful" << endl;
    	}else{
    		cout << "ugly" << endl;
    	}
    }

  2. #2
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    You can't use the == operator to compare character arrays. Use std::string instead of char[]'s. #include <string> too. If you can't ust std::string's (for assignment restriction reasons due to course or something), look into strcmp

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You have void main(). See the FAQ. You include windows.h for no reason. You don't allocate space for the input.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed