mucahitdemir / Direct-Memory-Access-DMA-Programming-with-STM32F4xx

4 stars 0 forks source link

How do I properly compare strings in C? #14

Open mucahitdemir opened 2 years ago

mucahitdemir commented 2 years ago

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.

bilalkutuk commented 2 years ago

The strcmp() compares two strings character by character. If the strings are equal, the function returns 0.