Code::Blocks Forums
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
As usual while waiting for the next release - don't forget to check the
nightly builds
in the forum.
Home
Help
Search
Login
Register
Code::Blocks Forums
»
User forums
»
Using Code::Blocks
»
char in C::B leading to a skip in else
« previous
next »
Send this topic
Print
Pages: [
1
]
Go Down
Author
Topic: char in C::B leading to a skip in else (Read 6515 times)
wrightjh
Guest
char in C::B leading to a skip in else
«
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;
Logged
stahta01
Lives here!
Posts: 7790
Re: char in C::B leading to a skip in else
«
Reply #1 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.
Logged
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ.
http://wiki.codeblocks.org
Jenna
Administrator
Lives here!
Posts: 7252
Re: char in C::B leading to a skip in else
«
Reply #2 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.
«
Last Edit: March 01, 2011, 06:56:14 am by jens
»
Logged
Send this topic
Print
Pages: [
1
]
Go Up
« previous
next »
Code::Blocks Forums
»
User forums
»
Using Code::Blocks
»
char in C::B leading to a skip in else