Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: wrightjh on February 28, 2011, 11:56:04 pm

Title: char in C::B leading to a skip in else
Post by: wrightjh on February 28, 2011, 11:56:04 pm
I'm new to using C::B and used to code using Visual Basic 6

I've been searching for ways to get my code to use the "else" but every time is goes straight to the if even if I don't type "gregg."
Could this be due to the way that I am writing char? I tried "char name[15];" but I still does the same thing. Is this a problem with the way I am writing code or because C::B is different? If you have any Ideas they would be very helpful.

#include <iostream>
#include <string>
using namespace std;
int main()
{
    char[15] name;
    cout<< "What is your name? ";
    cin>> name;
    if (name == "Gregg" or "gregg")
    cout<< "Screw You";

    else
    cout<< "Hi " <<name<<  " How are you?";
    return 0;
Title: Re: char in C::B leading to a skip in else
Post by: stahta01 on March 01, 2011, 02:17:50 am
Read about strcmp and post your programming questions an another site!!!
Like http://cboard.cprogramming.com/c-programming/

Tim S.
Title: Re: char in C::B leading to a skip in else
Post by: Jenna on March 01, 2011, 06:53:46 am
As Tim wrote this is a general programming question and not C::B related.
This is a violation of our forum rules !

Topic locked !!

By the way:
you should use C++syntax in your C++-programs, not VB-syntax or a mix of both as you did.