home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tyc
/
list17_8.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-16
|
545b
|
30 lines
/* The strncmp() function. */
#include <stdio.h>
#include <string.h>
char str1[] = "The first string.";
char str2[] = "The second string.";
main()
{
size_t n, x;
puts(str1);
puts(str2);
while (1)
{
puts("\n\nEnter number of characters to compare, 0 to exit.");
scanf("%d", &n);
if (n <= 0)
break;
x = strncmp(str1, str2, n);
printf("\nComparing %d characters, strncmp() returns %d.",
n, x);
}
}