You can't (usefully) compare strings using != or ==, you need to use strcmp:

while (strcmp(check,input) != 0)

The reason for this is because != and == will only compare the base addresses of those strings. Not the contents of the strings themselves.

Answer from Mysticial on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ ref_string_strcmp.php
C string strcmp() Function
For this comparison characters at the same position from both strings are compared one by one, starting from the left until one of them does not match or the end of a string has been reached. There are three possible scenarios: If the end of both strings has been reached without any mismatches then the function returns zero. At the first mismatch, if the ASCII value of the character in the first string is greater then the function returns a positive number.
๐ŸŒ
W3Schools
w3schools.in โ€บ c-programming โ€บ examples โ€บ compare-two-strings-using-strcmp
C Program to Compare Two Strings Using strcmp
#include<stdio.h> #include<string.h> ... return 0; } ... This program is used to compare whether two given strings are equal or not using a predefined function strcmp()....
๐ŸŒ
W3Schools Blog
w3schools.blog โ€บ home โ€บ how to compare strings in c
How to compare strings in c - W3schools
November 22, 2022 - int main(int argc, char const *argv[]) { char string1[] = {"tutorials point"}; char string2[] = {"tutorials point"}; //using function strcmp() to compare the two strings if (strcmp(string1, string2) == 0) printf("Yes 2 strings are same\n"); else printf("No, 2 strings are not same\n" ); return 0; } ...
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ library-function โ€บ string.h โ€บ strcmp
C strcmp() - C Standard Library
#include <stdio.h> #include <string.h> int main() { char str1[] = "abcd", str2[] = "abCd", str3[] = "abcd"; int result; // comparing strings str1 and str2 result = strcmp(str1, str2); printf("strcmp(str1, str2) = %d\n", result); // comparing strings str1 and str3 result = strcmp(str1, str3); printf("strcmp(str1, str3) = %d\n", result); return 0; }
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ strcmp-in-c
strcmp() in C %%sep%% %%sitename%% - GeeksforGeeks
December 13, 2025 - The strcmp function in C is used to compare two strings, with syntax: int strcmp(const char *str1, const char *str2);, where str1 and str2 are the strings to compare.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ strcmp-in-c-how-to-compare-strings-in-c
strcmp in C โ€“ How to Compare Strings in C
April 27, 2023 - As the function strcmp() gives a boolean output (true/false, or 0/1), I have taken another int variable named result to store the boolean value ( 1 for true and 0 for false). The strcmp() function compares the two strings, and finds out that ...
๐ŸŒ
W3Schools
w3schools.in โ€บ c-programming โ€บ examples โ€บ compare-two-strings-without-using-strcmp
C Program to Compare Two Strings Without Using strcmp
This C program is used to compare two strings without using strcmp function. ... #include<stdio.h> #include<string.h> int cmpstr(char s1[10], char s2[10]); int main() { char arr1[10] = "Nodalo"; char arr2[10] = "nodalo"; printf(" %d", cmpstr(arr1, arr2)); //cmpstr() is equivalent of strcmp() ...
Find elsewhere
๐ŸŒ
LabEx
labex.io โ€บ questions โ€บ how-to-compare-strings-in-c-136079
How to Compare Strings in C | LabEx
July 25, 2024 - Learn how to compare strings in C using strcmp function, characterbycharacter methods, and wildcard matching for effective programming.
๐ŸŒ
Programming Simplified
programmingsimplified.com โ€บ c-program-compare-two-strings
String compare in C | Programming Simplified
int compare_strings(char a[], char b[]) { int c = 0; while (a[c] == b[c]) { if (a[c] == '\0' || b[c] == '\0') break; c++; } if (a[c] == '\0' && b[c] == '\0') return 0; else return -1; } We can make a function to check if two strings are similar or not by using character pointers.
๐ŸŒ
Cplusplus
cplusplus.com โ€บ reference โ€บ string โ€บ string โ€บ compare
std::string::compare()
Compares the value of the string object (or a substring) to the sequence of characters specified by its arguments. The compared string is the value of the string object or -if the signature used has a pos and a len parameters- the substring that begins at its character in position pos and spans ...
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ string comparison in c
String Comparison in C - Scaler Topics
January 11, 2024 - There are four methods for string comparison in C. String comparison by using strcmp() String Library function. String comparison without using strcmp() function . String comparison by using pointers.
๐ŸŒ
GNU
gnu.org โ€บ software โ€บ libc โ€บ manual โ€บ html_node โ€บ String_002fArray-Comparison.html
String/Array Comparison (The GNU C Library)
Unlike most comparison operations in C, the string comparison functions return a nonzero value if the strings are not equivalent rather than if they are. The sign of the value indicates the relative ordering of the first part of the strings that are not equivalent: a negative value indicates that the first string is โ€œlessโ€ than the second, while a positive value indicates that the first string is โ€œgreaterโ€. The most common use of these functions is to check only for equality.
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ c-program-to-compare-two-strings
C program to Compare Two Strings without using strcmp()
April 4, 2025 - #include <stdio.h> #include <string.h> int Compare_Strings(char *Str1, char *Str2); int main() { char Str1[100], Str2[100]; int result; printf("\n Please Enter the First : "); gets(Str1); printf("\n Please Enter the Second : "); gets(Str2); result = Compare_Strings(Str1, Str2); if(result < 0) { printf("\n str1 is Less than str2"); } else if(result > 0) { printf("\n str2 is Less than str1"); } else { printf("\n str1 is Equal to str2"); } return 0; } int Compare_Strings(char *Str1, char *Str2) { int i = 0; while(Str1[i] == Str2[i]) { if(Str1[i] == '\0' && Str2[i] == '\0') break; i++; } return Str1[i] - Str2[i]; }
๐ŸŒ
W3Resource
w3resource.com โ€บ c-programming โ€บ string โ€บ c-strcmp.php
C strcmp() function
A correct_password string is defined as " Secret1$23". The user is prompted to enter a password, which is stored in user_input. strcmp() compares user_input with correct_password.
๐ŸŒ
wikiHow
wikihow.tech โ€บ computers and electronics โ€บ software โ€บ programming โ€บ c programming languages โ€บ how to compare two strings in c programming: 10 steps
How to Compare Two Strings in C Programming: 10 Steps
June 16, 2025 - Use an .If...Else statement to perform the comparison. Now that you have the function in place, you can use an If...Else statement to display which string is longer.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ c compare strings
How to Compare Strings in C | Delft Stack
March 12, 2025 - This article introduces how to compare strings in C, covering essential methods like `strcmp`, `strncmp`, and manual comparison. Learn the nuances of string representation and gain practical examples to enhance your C programming skills. Whether you're a beginner or looking to refine your ...
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ c-programming โ€บ c-compare-strings
How to Compare Strings in C?
November 20, 2020 - If s1=โ€appleโ€ and s2=โ€bananaโ€, when we compare both the strings like strcmp(s1,s2), then this function returns a negative integer because ASCII value of โ€˜aโ€™ is less than the ASCII value of โ€˜bโ€™. If both the first characters are same then it goes for second characters.
๐ŸŒ
TechOnTheNet
techonthenet.com โ€บ c_language โ€บ standard_library_functions โ€บ string_h โ€บ strcmp.php
C Language: strcmp function (String Compare)
An array to compare. The strcmp function returns an integer. The return values are as follows: In the C Language, the required header for the strcmp function is: ... /* Example using strcmp by TechOnTheNet.com */ #include <stdio.h> #include <string.h> int main(int argc, const char * argv[]) ...
๐ŸŒ
Quora
quora.com โ€บ How-can-we-compare-two-strings-efficiently-in-C-or-C
How can we compare two strings efficiently in C or C++? - Quora
Answer (1 of 6): There is no way to compare strings efficiently. because they are strings. Is far better to compare 2 numbers than 2 strings. because when you compare numbers you ony need to compare 1 number. and such number can never be null. ...