Im confused about switch case, please, help

Well, really, im a noob here in programing. And now i am trying to learn about switch case, but...i found new coding language.

Like cout and cin.

The day before, i usually use printf and scanf instead of cout and cin. So my question is:

1. Is it okay to use printf and scanf in switch-case ?

2. When i type cout and cin in Visual C++ 2010, the words are not colored, is it an old language?

3. If i use the printf and scanf language, is there any changes ? i mean, if we want to build a switch-case program using printf and scanf instead of cin and cout, we only replace cin and cout language with printf and scanf, or is there anything else ?

Thanks
1) Yes
2) cout and cin are objects, just how int x; would not color "x". (AFAIK)
3) I think you are misunderstanding something. printf and scanf are mainly used in C (and are also included in C++). cout and cin are used in C++ (they do not exist in C).

They are not "languages"; they are part of the standard library for a language.
so fireddraco, which is easier? printf scanf or cin cout? :D :D
It depends on the specifics of what you're doing and what you're used to use. iostreams are generally safer (as in, if used properly they'll never make your program crash or make it exploitable by crackers), but printf() and its siblings (sprintf(), fprintf(), etc.) let you do certain things with streams with slightly less code. For example, printing a hex number padded to eight digits with zeroes with printf() is
printf("%08x",number);
I honestly can't remember what the equivalent code with iostreams is, because it's ridiculous.

You should avoid scanf() at all costs, though.
why do i have to avoid scanf ??
make your program crash or make it exploitable by crackers
One thing I've found, which may be specific to my system, is that printf, puts etc. are very much faster than the equivalent cout statements. For many applications this doesn't matter, but for animations or games etc. then then it could be vital.

As for input, I personally have never liked scanf, even in pure C code there are usually alternatives. But that may just be my own bias.
Topic archived. No new replies allowed.