I want to use strcmp(); in my program.
I have read that it needs two string constants.
If I have a string say string1[99], and string2[99]. I input data into it and add a trailling \0. Does adding the trailing \0 create the string constant? My book states it has to be a string enclosed in "string". Can we not use a string scaned in by sscanf? I want to compare the two strings with the following syntax.
strcmp(string1,string2);.
sample program... sorry no compiler to check
Code:
#include<string.h>
#include<stdio>
char string1[99];
char string2[99];
memset(string1,'\0',99);
memset(string2,'\0',99);
int x;
scanf("%s%s",string1,string2);
x=strcmp(string1,string2);
printf("%i",x);