I know you use strcmp() with strings and that if it is equal to zero, they match. But, how do you see if one string is less than the other? I want to compare SSN's to see if 12345620 is less than or greater than 123456708. Thanks for any input.
tat2dlady
0
Light Poster
Recommended Answers
Jump to PostWith strcmp. The result would be less or greater than zero.
#include <stdio.h> #include <string.h> int main(void) { static const char a[] = "12345620", b[] = "123456708"; int result = strcmp(a, b); printf("%s %s %s\n", a, result < 0 ? "<" : result > 0 ? ">" …
Jump to Post>But, how do you see if one string is less than the other?
strcmp returns one of three values: 0 if the strings are of equal length and content, a value less than 0 if the first string is shorter or smaller in value than the second string, and a …
All 5 Replies
Dave Sinkula
2,398
long time no c
Team Colleague
Narue
5,707
Bad Cop
Team Colleague
indianscorpion2
-1
Junior Poster in Training
Auron
0
Unverified User
Dogtree
23
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.