I wrote this code in C:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
char string1[20];
char string2[20];
strcpy(string1, "Heloooo");
strcpy(string2, "Helloo");
printf("%d", strcmp(string1, string2));
return(0);
}
Should console print value 1 or difference between ASCII
values of o
and \0
character i.e. 111? On this website, it is written that this should give out put 111, but when I run it on my laptop, it shows 1. Why?
man strcmp
. NOTES: 1) your "website" is wrong. 2) strcmp() expects a C string (a null-terminated char array); not an individual "char" value. – Novak-1
it may also give the difference in ascii-values – Carlile