I'm using DJGPP C compiler. Trying sample code. I don't know why this code when run will not let me input the second string to compare. It just seems to automatically hit enter on it and go to asking for input on # of characters to compare.
Code:
include <stdio.h>
#include <string.h>
main()
{
char string1[20];
char string2[20];
int length;
printf("\nEnter first string to compare :");
scanf("%s",string1);
printf("\nEnter second string to compare :");
scanf("%s",string2);
printf("\nEnter the number of characters to compare :");
scanf("%d",&length);
if(!strncmp(string1,string2,length))
printf("The first %d characters of String 1 equals String 2\n",length);
}