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 4 12279
"Trying_Har der" <fr***********@ yahoo.com> wrote in message
news:b0******** *************** ***@posting.goo gle.com...
| 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. fr***********@y ahoo.com (Trying_Harder) wrote in
news:b0******** *************** ***@posting.goo gle.com: 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 fr***********@y ahoo.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
Ben Pfaff <bl*@cs.stanfor d.edu> wrote: fr***********@y ahoo.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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"
>>>c = extract(a,b)
>>>print c
"abcdefghijklmnop"
|
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 interchangeable in all
circumstances (as long as they're paired) so there's no overloading to
muddy the language. Of course there could be some interesting problems
with current code that doesn't make a distinction, but it would be dead
easy to fix...
|
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 any arbitrary data, even binary data such as photos and movies.They
are of course also good for their traditional role of storing and
manipulating text."
This view of strings is about a decade out of date with modern
programmimg practice. From...
|
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 sets of
character strings from the user. Then I want to run through each
element and compare the two strings. If they match I print they
match... I'm having a bit of trouble with the actual loop through each
array using the pointers and comparing...
|
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
| |
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 character array
that you must use the strcpy() function?
|
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 read (the file will be written by only this program); file can be either in text or binary (preferably binary as the files may be read repeatedly); the amount and size of strings in the array won't be known until run time (in the example I have it in...
|
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
Nordrassil-Horde
Draenor-Alliance
Nordrassil-Alliance
Nordrassil-Neutral
Draenor-Horde
|
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
____________________________________
| |
| ------------------ |
| | BUTTON | |
| ...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |