Yes, I understand what you are getting at.
Compare one variable at a time, got it.
as for the ?:, I recently read about , I don't remember the exact page though. I understand it.
EDIT: Found it; Here is how I interpreted it.
Code: Select all
condition ? result1 : result2
If condition is true the expression will return result1, if it is not it will return result2.
One thing I've yet to get to in a tutorial is defining other (functions? I think)
int main()
but I want to also make another block of code that I can refer to at some point in time:
example
Code: Select all
int main()
{
if(sky == blue)
{
secondarycodeblock();
}
}
secondarycodeblock()
{
cout << "Hi, the Sky is Blue.\n";
}
I don't really completely understand that.
Another thing I need help with (This I cannot find really anywheres)
Converting string formats. Let's say in that program I'm trying to ask the user for a "yes" or "no" answer.
What if the user says "Yes"? The program will take if(answ == "yes") as false, and go to the next block
Alternatively, I know I can include every possibility of "yes" by separating them by the || operator, but it is a bit simpler to convert the string to lowercase and just test for "yes" or "no"
So far; this is the only method I know.
Code: Select all
#include <algorithm>
(...)
transform ( answ.begin(), answ.end(), answ.begin(), ptr_fun(::tolower) );
What is required to do it in a more simplistic manner? If there are no common C++ codes to achieve this, how hard(and what do I need to do) would it be to set up a .h file(or whatever) to #include, and be able to "create" a command so-to-speak?
example
Code: Select all
#include <"strconvert.h"> //use the complicated way to create "function" or "command" to simply refer to for use during programs
(...)
strlower(variablenamehere); //created command