Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Two Types of C?!


  • Please log in to reply

#1
Joeturf

Joeturf

    Member

  • Member
  • PipPipPip
  • 158 posts
Hey All.

After looking through various C and C++ codes I am kind of confused about the "two types" of C that I've encountered. In the class that I'm in right now, we are using the functions scanf and printf for input and output. However, some other C programmers on google or whatnot use cin and cout for input and output. Isn't it kind of redundant to have two different functions that do the same thing in one language?! I feel like I have to learn both of these "types" of C because I have no clue how the cin and cout keywords work, but know how printf and scanf work.

Is it necessary for me to learn cin and cout on top of printf and scanf? - because right now I feel like I'm only learning half of the language.

Thanks for the help!
  • 0

Advertisements


#2
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
They are both valid ways of getting input and output in C++. Printf and Scanf are usually acceptable in most circumstances, though cin and cout supposedly have advantages when doing lots of complex work with numbers. I haven't personally encountered a place where cin and cout perform better than printf and scanf however.

If you are programming in C, not C++, then you cannot use cin and cout! They are for C++ only. From what I have read, stdin and stdout appear to be the C equivalents of cin and cout, though I can't guarantee that they work in the same way.
  • 0

#3
Joeturf

Joeturf

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 158 posts
Ah I see. Well, I think I will stick to printf and scanf until I am comfortable enough to move on to other things =). At least now I know that cin and cout is exclusive to C++ so that is good to know.

Thanks!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP