Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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