473,902 Members | 3,778 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strcmpi

Hi
Im doing a C code using GCC.
I tried to compare (case Incensitive) two strings.. but it seems dont
"know" strcmpi.. Im using 2 headers string.h and stdio.h
How can I do this?

Ex:
#include <stdio.h>
#include <string.h>

int main (void)
{
char * str = "Case";
char * str1 = "cAsE";

if (strcmpi(str,st r1)==0)
printf("Same\n" );
else
printf("Sorry\n ");
}

Tks

Eduardo Elias Camponez
Nov 13 '05
14 29428
ca******@yahoo. com.br (Eduardo Elias Camponez) writes:
Hi
Im doing a C code using GCC.
I tried to compare (case Incensitive) two strings.. but it seems dont
"know" strcmpi.. Im using 2 headers string.h and stdio.h
How can I do this?

Ex:
#include <stdio.h>
#include <string.h>

int main (void)
{
char * str = "Case";
char * str1 = "cAsE";

if (strcmpi(str,st r1)==0)
printf("Same\n" );
else
printf("Sorry\n ");
}


There is no standard C library function for performing
case-insensitive comparisons against two strings. (OT:) If you
are willing to limit portability to POSIX platforms and systems
which provide the function as an extension, you may use
strcasecmp().

-Micah
Nov 13 '05 #11
Eduardo Elias Camponez wrote:
Hi
Im doing a C code using GCC.
I tried to compare (case Incensitive) two strings.. but it seems dont
"know" strcmpi.. Im using 2 headers string.h and stdio.h
How can I do this?

Ex:
#include <stdio.h>
#include <string.h>

int main (void)
{
char * str = "Case";
char * str1 = "cAsE";

if (strcmpi(str,st r1)==0)
printf("Same\n" );
else
printf("Sorry\n ");
}

Tks

Eduardo Elias Camponez


Thank you for your post, Eduardo.

#include <stdio.h>
#include <string.h>

int main()
{
char * str = "Case";
char * str1 = "cAsE";

/* strcmp returns 0 if the two strings are identical */

if (!strcmp(str, str1))
printf("Same\n" );
else
printf("Sorry\n ");

return 0;
}

--Steve

Nov 13 '05 #12
Irrwahn Grausewitz <ir************ *****@freenet.d e> wrote in message news:<ba******* *************** **********@4ax. com>...
"j" <ja*******@bell south.net> wrote:

"Eduardo Elias Camponez" <ca******@yahoo .com.br> wrote in message
news:a3******* *************** ****@posting.go ogle.com...
Hi
Im doing a C code using GCC.
I tried to compare (case Incensitive) two strings.. but it seems dont
"know" strcmpi.. Im using 2 headers string.h and stdio.h
How can I do this?

Ex:
#include <stdio.h>
#include <string.h>

int main (void)
{
char * str = "Case";
char * str1 = "cAsE";

if (strcmpi(str,st r1)==0)
printf("Same\n" );
else
printf("Sorry\n ");
}

Tks

Eduardo Elias Camponez


Just provide your own version of ``strcmpi'' .. although I think you might
want to rename it, since str* is reserved by the implementation if I am not
mistaken.

To be exact, ISO/IEC 9899:1999 states:

7.26.11 String handling <string.h>
Function names that begin with str, mem, or wcs and a lowercase
letter may be added to the declarations in the <string.h> header.

A perfectly valid name would be e.g.: strCmpi


Under C90, external identifiers need not be distinguishable by case,
and C90 implementations are only required to recognise external
identifiers up to 6 significant characters (IIRC).

So, strCmpi can theoretically have the same signature as strcmp,
STRCMP, StrCMP, StrCmp, etc...

--
Peter
Nov 13 '05 #13
Steve Zimmerman <st******@sonic .net> wrote:
Eduardo Elias Camponez wrote:
Hi
Im doing a C code using GCC.
I tried to compare (case Incensitive) two strings.. but it seems dont ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^ "know" strcmpi.. Im using 2 headers string.h and stdio.h
How can I do this?


Thank you for your post, Eduardo.

#include <stdio.h>
#include <string.h>

int main()
{
char * str = "Case";
char * str1 = "cAsE";

/* strcmp returns 0 if the two strings are identical */

if (!strcmp(str, str1))
printf("Same\n" );
else
printf("Sorry\n ");

return 0;
}

Steve,

how does this code compare two strings _case insensitive_?

Regards

Irrwahn
--
Great minds run in great circles.
Nov 13 '05 #14
ai***@acay.com. au (Peter Nilsson) wrote:
Irrwahn Grausewitz <ir************ *****@freenet.d e> wrote:
"j" <ja*******@bell south.net> wrote: <SNIP>
>Just provide your own version of ``strcmpi'' .. although I think you might
>want to rename it, since str* is reserved by the implementation if I am not
>mistaken.

To be exact, ISO/IEC 9899:1999 states:

7.26.11 String handling <string.h>
Function names that begin with str, mem, or wcs and a lowercase
letter may be added to the declarations in the <string.h> header.

A perfectly valid name would be e.g.: strCmpi


Under C90, external identifiers need not be distinguishable by case,
and C90 implementations are only required to recognise external
identifiers up to 6 significant characters (IIRC).

So, strCmpi can theoretically have the same signature as strcmp,
STRCMP, StrCMP, StrCmp, etc...


That's why I was referring to C99... :)

Irrwahn
--
Great minds run in great circles.
Nov 13 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
1541
by: Jenski182 | last post by:
Is this from a good coder? or a rubbish one? Whichever way, it was paid for his services, just want to know if its worth while.... Thanks Jen x #include <iostream.h> #include <conio.h>
2
1404
by: threetoast | last post by:
Is there any way to have a class function to search a struct, but the field searched be passed to it as, say, a character array? Ex: int book::searchChar(char r, char tyco) { for (int p=0; p<x; p++) { if (strcmpi(library.tyco, r)==0) { return p;
3
4601
by: Michael Sgier | last post by:
Hello I want to replace a windows bitmap load function through an equivalent SDL function. I should extract the img height etc. and assign it to the terrainTex array. I've also three beginner questions: -Concerning that array why is texID used? terrainTex doesn't state the first element? What does terrainTex represent? Especially the "0". -How do i transfer terrainTex back to the calling terrain.cpp. the
13
29281
by: GRoll21 | last post by:
I know there is a function but I cannot seem to find it. There should be a way to uppercase a char right? Here is what I got. cout << "Enter title of a book for look up: "; cin >> firstString; if (strcmp(toupper(firstString), toupper(bookTitle)) == 0)
8
2238
by: chook | last post by:
How i can call my function with some parameters, if i have a pointer to this function
0
897
by: Brett | last post by:
I'm compiling a very small project with some matlab includes and getting an internal compile error. There are no optimisations in this project, and I'm not using managed code. v:\eqclient\include\Matlab6p1\cpp\mlmif.h(6341) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more...
10
2095
by: mansimisha | last post by:
Hi to everybody.. I need a help need to have a program to represent directory structure(a directory can contain any number of directory or files) alos write a programme to insert one element nd find one element in structure. If anyone can do this program than pls mail me. PLSSSSSSSSSS
2
1711
by: hepsibasushmap | last post by:
Hi all, I had downloaded the Xerces C++ DOMLibrary and had also prepared a parser which reads a file which is similar to our Menu. Now in the similarway iam trying to prepare a parser for one more Schema which is as follows: <ConfigurationFile Name="EventConfiguration" Id="ID_EVENTCONFIGURATION"> <Events Name="MouseEvents" Id="ID_MOUSEEVENTS">
19
4058
by: J4CK4L | last post by:
Hi everyone, i want to compare a string whith another in a file called wordlist.txt I've this code... int Scan(char Search) { char *pch; pch = strtok (Search," -,."); while (pch != NULL) {
0
9997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9845
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10870
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7205
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4725
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4306
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.