469,301 Members | 2,272 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,301 developers. It's quick & easy.

How Do I Compare Two Strings in C++?

codegeekguy
Hi, I wanted to know if is there any simple code that can compare two different strings in C++ easily.
3 Weeks Ago #1

✓ answered by bulieme

example
Expand|Select|Wrap|Line Numbers
  1. str a = 'h'
  2.  
  3. if( 'h' == a ){
  4.  
  5. }else{
  6.  
  7. }
  8.  

2 6195
dev7060
501 Expert 256MB
How Do I Compare Two Strings in C++?
- Relational operators
- std::compare()
- strcmp() {C library function}
- Write custom code.

Hi, I wanted to know if is there any simple code that can compare two different strings in C++ easily.
Define 'simple code'.
2 Weeks Ago #2
bulieme
2 2Bits
example
Expand|Select|Wrap|Line Numbers
  1. str a = 'h'
  2.  
  3. if( 'h' == a ){
  4.  
  5. }else{
  6.  
  7. }
  8.  
2 Weeks Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by J.W. | last post: by
1 post views Thread by al | last post: by
3 posts views Thread by Drew | last post: by
14 posts views Thread by Samuel R. Neff | last post: by
3 posts views Thread by Jim Carlock | last post: by
reply views Thread by Diego Martins | last post: by
6 posts views Thread by shapper | last post: by
2 posts views Thread by Thenu | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.