473,398 Members | 2,404 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,398 software developers and data experts.

strings.h

Firstly, are functions defined in strings.h (`strcasecmp' and
`strncasecmp')
ANSI? if yes , then why am I getting an implicit declaration warning
only
with -Wall (Warnings all) flag? and if not, why am I not getting
warnings
with `gcc -ansi -pedantic blah.c'

Secondly , is there a function in `C' for comparing strings ignoring
their cases? Only criterion is this has to be ANSI compliant (being
precise, it
should compile without warnings with the following flags `-ansi
-pedantic &
-Wall' ).
After scouring through some newsgroup archives, I have got a hint
there isnt
any standard C function for this.
Conincidentally, I have always preferred using my own functions for
such
a logic and hence never encountered this problem before.
Thanks in advance,

f
Nov 13 '05 #1
4 12267
"Trying_Harder" <fr***********@yahoo.com> wrote in message
news:b0**************************@posting.google.c om...
| Firstly, are functions defined in strings.h (`strcasecmp' and
| `strncasecmp')
| ANSI? if yes , then why am I getting an implicit declaration warning
| only
| with -Wall (Warnings all) flag? and if not, why am I not getting
| warnings
| with `gcc -ansi -pedantic blah.c'

I guess because glibc isn't 100% perfect. Most implementations give some
warnings (when putting the warning flags up full-throttle).

| Secondly , is there a function in `C' for comparing strings ignoring
| their cases? Only criterion is this has to be ANSI compliant (being
<snip>

The only thing I can think of at the to of my head (at 4am) is to write a
function taking two const char* parameters, use temp char's and store
results from tolower() and check them one by one by iterating over each.
Nov 13 '05 #2
fr***********@yahoo.com (Trying_Harder) wrote in
news:b0**************************@posting.google.c om:
Firstly, are functions defined in strings.h (`strcasecmp' and
`strncasecmp') ANSI?
No. ANSI C does not require the functions 'strcasecmp' and
'strncasecmp' to be provided.
if yes , then why am I getting an implicit declaration
warning only with -Wall (Warnings all) flag? and if not,
why am I not getting warnings with `gcc -ansi -pedantic
blah.c'
All external identifiers starting with 'str' and a lower case
letter are reserved for use by the implementation. This means
that although the two functions are not required, a conforming
implementation is allowed to provide them.

As to why gcc does what it does, I can have a guess. It may
be because gcc is providing the functions, but no declarations
of them. In this situation, C89 does not require a diagnostic,
and because the functions return int and have char * arguments
(I assume) it is in fact required to work. However, an
implementation is allowed to give any diagnostics it likes,
hence the "implicit declaration warning" with -Wall.
Secondly , is there a function in `C' for comparing strings
ignoring their cases? Only criterion is this has to be ANSI
compliant (being precise, it should compile without warnings
with the following flags `-ansi -pedantic & -Wall' ).


The are no functions for case blind compares required by the
standard, but as I said, they are allowed.

Phil T
Nov 13 '05 #3
fr***********@yahoo.com (Trying_Harder) writes:
Firstly, are functions defined in strings.h (`strcasecmp' and
`strncasecmp') ANSI? if yes , then why am I getting an implicit
declaration warning only with -Wall (Warnings all) flag? and if
not, why am I not getting warnings with `gcc -ansi -pedantic
blah.c'
No, ANSI says nothing about strings.h at all. The standard
string header is <string.h>, without any `s'. Furthermore, those
aren't standard functions.
Secondly , is there a function in `C' for comparing strings
ignoring their cases?


No. Actually, you could use strcoll() if you want a
locale-specific ordering, but that does more than just
case-insensitive comparison.
--
"We put [the best] Assembler programmers in a little glass case in the hallway
near the Exit sign. The sign on the case says, `In case of optimization
problem, break glass.' Meanwhile, the problem solvers are busy doing their
work in languages most appropriate to the job at hand." --Richard Riehle
Nov 13 '05 #4
Ben Pfaff <bl*@cs.stanford.edu> wrote:
fr***********@yahoo.com (Trying_Harder) writes:
Firstly, are functions defined in strings.h (`strcasecmp' and
`strncasecmp') ANSI? if yes , then why am I getting an implicit
declaration warning only with -Wall (Warnings all) flag? and if
not, why am I not getting warnings with `gcc -ansi -pedantic
blah.c'

No, ANSI says nothing about strings.h at all. The standard
string header is <string.h>, without any `s'. Furthermore, those
aren't standard functions.


Funny. I see at least one 's' in <string.h>. Or are you talking
about <tring.h>?

Alex
Nov 13 '05 #5

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

Similar topics

20
by: Ravi | last post by:
Hi, I have about 200GB of data that I need to go through and extract the common first part of a line. Something like this. >>>a = "abcdefghijklmnopqrstuvwxyz" >>>b = "abcdefghijklmnopBHLHT"...
17
by: Gordon Airport | last post by:
Has anyone suggested introducing a mutable string type (yes, of course) and distinguishing them from standard strings by the quote type - single or double? As far as I know ' and " are currently...
16
by: Paul Prescod | last post by:
I skimmed the tutorial and something alarmed me. "Strings are a powerful data type in Prothon. Unlike many languages, they can be of unlimited size (constrained only by memory size) and can hold...
4
by: agent349 | last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1 == array2)). However, I've been trying to compare two arrays using pointers with no success. Basically, I want to take three...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
6
by: Broeisi | last post by:
Hello, I wrote the tiny progam below just to understand arrays and strings better. I have 2 questions about arrays and strings in C. 1. Why is it that when you want to assign a string to an...
2
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be...
19
by: pkirk25 | last post by:
I wonder if anyone has time to write a small example program based on this data or to critique my own effort? A file called Realm List.html contains the following data: Bladefist-Horde...
95
by: hstagni | last post by:
Where can I find a library to created text-based windows applications? Im looking for a library that can make windows and buttons inside console.. Many old apps were make like this, i guess ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.