Function Descriptions : strcmp (2024)

Function Descriptions : strcmp (1)
Chapter Contents
Function Descriptions : strcmp (2)
Previous
Function Descriptions : strcmp (3)
Next

strcmp


Compare Two Null-Terminated Strings
Portability:ISO/ANSI C conforming, UNIX compatible
SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO
SYNOPSIS
#include <string.h>int strcmp(const char *str1, const char *str2);
DESCRIPTION

strcmpcompares two character strings (str1 and str2) using the standard EBCDIC collating sequence. The return value has the same relationship to 0 as str1 has to str2. If two stringsare equal up to the point at which one terminates (that is, contains a nullcharacter), the longer string is considered greater.

RETURN VALUE

The return value from strcmp is 0 if the two strings are equal, less than 0 if str1 compares less than str2, andgreater than 0 if str1 compares greaterthan str2. No other assumptions shouldbe made about the value returned by strcmp.

CAUTION

If one of the arguments of strcmp is not properly terminated, a protection or addressing exceptionmay occur. If one of the arguments to the built-in version of strcmp is a constant, the compiler generates a CLC instruction to performthe entire comparison. If the variable argument is not null terminated, thecharacter-by-character comparison may perform as expected, but a comparisonby the CLC instruction may cause an addressing exception in rare cases.

IMPLEMENTATION

The compiler generates inline code for strcmp unless strcmp is undefined (by an #undef statement)to prevent this. The inline code may still call a library routine in specialcases.

EXAMPLE
#include <lcstring.h>#include <stdio.h>#include <stdlib.h>main(){ char command[20]; int n = 0; for(;;) { ++n; printf("Enter command # %d\n", n); puts("Enter quit to terminate/any other command to continue"); gets(command_; if (strcmp(command, "quit") == 0) break; /* Determine whether command is equal to quit. */ strlwr(command); if (strcmp(command, "quit") == 0) exit(0); puts("Did you meant to say quit? (Case is significant.)"); }}
RELATED FUNCTIONS

memcmp, strcoll, strncmp, strxfrm

SEE ALSO
Function Descriptions : strcmp (4)
Chapter Contents
Function Descriptions : strcmp (5)
Previous
Function Descriptions : strcmp (6)
Next
Top of Page

Function Descriptions : strcmp (8)

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.

Function Descriptions : strcmp (2024)
Top Articles
Bybit Review (2023) – ☑️ Pros and Cons Revealed.
I would like to resize the charts of my layout — TradingView
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 6063

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.