Thread: Newbie Help!

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> The problem with mine was you cant == a string it has to be a int etc.

    Unfortunately, that's wrong. Note that both g4j31a5 and MacGyver acknowledged it later.

    You can use == on a string. The problem was the missing quotes. Try your original code but add quotes around bob.

  2. #17
    Registered User
    Join Date
    Jul 2008
    Posts
    17
    Thankyou.

    I learn new stuff everyday.

    Is there anything else that you can teach me?

  3. #18
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> Is there anything else that you can teach me?
    Keep trying to do things on your own first, and when you get stuck feel free to ask questions here. You'll learn plenty.

  4. #19
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    @Swink: maybe one more minor thing. Add "std::" before the cin, cout, endl, and string. You won't get it to work without it. BTW the tutorials in this website can be found here.
    Last edited by g4j31a5; 07-20-2008 at 10:42 PM. Reason: Typo
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  5. #20
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> Add "std::" before the cin, cout, endl, and string. You won't get it to work without it.

    FYI, even though I prefer the std::, it can work without it if you have a using directive or using declarations. I assume Swink has that but just didn't include it in the posted code.

  6. #21
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Quote Originally Posted by Saimadhav View Post
    use this code instead
    Code:
    #include<iostream>
    using namespace std;
    main()
    {
    
                       char name[20];
                       cout<<"Enter your name";
                       cin>>name;
    
                        cin.get();
                        if(name==20)
    { 
    cout<<"Cool"<<endl;
    }
    }
    Your code is wrong. the "if(name==20)" will most likely returned false as you are comparing the pointer to the first character of the variable "name" against the integer 20. Not like what you wanted it to be.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  7. #22
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by Swink View Post
    I just search on google for a forum to ask my question
    Search on google for "Thinking in C++" and download the free electronic book and read it. That's certainly the best way to learn. Then ask questions on internet forums when you are stuck and you can't find the answer in the book.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 07:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 12:27 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM