String compare: how to use strncmp
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if(argc!=3) {
printf("Incorrect number of arguments.");
exit(1);
}
if(!strncmp(argv[1], argv[2], 8))
printf("The strings are the same.\n");
return 0;
}
Related examples in the same category