User forums > Using Code::Blocks

char in C::B leading to a skip in else

(1/1)

wrightjh:
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;

stahta01:
Read about strcmp and post your programming questions an another site!!!
Like http://cboard.cprogramming.com/c-programming/

Tim S.

Jenna:
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.

Navigation

[0] Message Index

Go to full version