473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to compare strings ignoring case

Im lost on this.

It should report whether or not, ignoring case, they are the same.

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. using namespace std;
  4. void main(void)
  5. {
  6.     char str1[25], str2[25], dif;
  7.     printf("\nEnter the first String:");
  8.     gets(str1);
  9.     printf("\nEnter the second String;");
  10.     gets(str2);
  11.  
  12.     dif = strcmp(str1, str2);                                       //using string functions
  13.  
  14.     if (dif>0)
  15.         printf("%s comes after %s", str1, str2);
  16.     else
  17.     {
  18.         if (dif<0)
  19.             printf("%s comes after %s", str2, str1);
  20.         else
  21.             printf("both the strings are same");
  22.     }
  23. }
Oct 29 '14 #1

✓ answered by weaknessforcats

strcmp just compares the strings. Therefore, X and x will compare not equal.

Use stricmp. That is a case insensitive version of strcmp.

1 1752
weaknessforcats
9,208 Expert Mod 8TB
strcmp just compares the strings. Therefore, X and x will compare not equal.

Use stricmp. That is a case insensitive version of strcmp.
Oct 29 '14 #2

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

Similar topics

5
by: josh dismukes | last post by:
/// Were having serious problems with this script it's basically the map script allowing player movement but the problem is in the QUERY and if statements on the cell type. Any help will be much...
3
by: Randell D. | last post by:
Folks, I'm working on an ecommerce website that deals with credit card expiry dates. The table has two columns for year and month. I currently have a select that says: ...
4
by: Brett conklin | last post by:
I have an xml document that I am trying to transform into HTML. This sounds straigt forward but the xml uses an format that I don't know how to xslt. Here is the format. <RESULTSET> <HIT>...
3
by: chris kramer | last post by:
i have an application that allows you to Select some text in a window, but no option to Copy it to the clipboard (nor does Ctrl-C or Shift-insert work, or right click etc..) i want to get these...
0
by: Prabha Govind Perumal | last post by:
im just going too eager in starting up with my win32 project...but just strugling to select one....hope some one help me with a proper guidence...im just tooo small a baby with vc++....but hope some...
15
by: Fergus Cooney | last post by:
Hi Everyone, I finished playing newgroupie this morning and went to bed. When I came back, I couldn't get any new messages for this group. I'm using Outlook Express. It showed the newsgroup...
0
by: Aws | last post by:
My crazy GridView !! I am using Visual Studio 2005, I have a problem with my GridView. I have one access .mdb table and when I update a record on the table EVERYTHING is perfect. I made a Web...
3
by: Shippy | last post by:
Please help, this is doing my head in!!!! I am sure it is something really simple and ovbious that I am missing but for the life of me I cant find where!!! I have this function... <script>...
1
by: imranay | last post by:
hey is there some body to tell me what will be the next step after imorting website. i have importeb my website named cruel_digger to yahworld.com but i dont know the nect step please help this dull...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.