Hot answers tagged

2

GOT IT! you need to format - if comparing hex, need to say 0x34 not 34.


1

Your problem is much more basic and simple. Look at these lines: char x; // a char variable char *y; // a pointer to a string y = "a"; // loads a string into memory at y if (x == y){ // compares a char and a string y is a pointer to a string, not a character. You are attempting to compare a char to a pointer. There are two ...


1

You can check for equality if it is a float a = 10.00; or int b = 10; or char c = 'a' or any other datatype variables like short,long, unsigned int but that is not the case for a string or char[] array, In C strings are stored as an array of characters char[] that means multiple characters in a single variable, when you write if( answer == "something&...


1

You're having problems because you can't use "==" to compare strings. You need to use a function call to strcmp() or maybe strcasecmp() It's a very, very common mistake by new programmers. I even did it myself when I was learning. ;-) If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


1

When compare_strings is called, notice that the first part of the function checks to see if the 2 strings have the same length. If they don't, the function immediately ends with return false; The loop will never be run. In your example, "David" and "DavidDDD" are different lengths so it will return false.


1

The compare python program is for running on the command line, so you can test your helpers.py functions that you've written. It is unrelated to the web-based application.


Only top voted, non community-wiki answers of a minimum length are eligible