hello someone could tell me how to make this condition condition (Day == "Wednesday") is a program that discounts movie tickets if it is Wednesday but it does not work.
hello someone could tell me how to make this condition condition (Day == "Wednesday") is a program that discounts movie tickets if it is Wednesday but it does not work.
If you use C-style character arrays you have to use a function that compares both arrays and returns the result of the comparison ... the character strings can not be directly compared but you can verify the result of a function:
char Dia[20] = /* ... */
if (strcmp(Dia, "miercoles") == 0)
{
// ...
}
Although since you are in C ++ you can use std::string
. This class has its own comparison operator, with which you can write in a natural way:
std::string Dia = "miercoles";
if( Dia == "miercoles" )
{
// ...
}
To compare 2 text strings in c the strcmp
You would use something like this:
if (strcmp(Dia, "miercoles") == 0) { /* descuenta las entradas de cine */ }
The function returns 0 when the 2 strings are equal
To compare two strings in c ++ you must:
string a = "A";
string a = "B";
if(!a.compare(b))
// Son iguales
else
// No lo son