Question:

what is the difference between getchar( ) and scanf( )?

by Guest9034  |  12 years, 9 month(s) ago

0 LIKES UnLike

what is the difference between getchar( ) and scanf( )?

 Tags: difference, getchar, scanf

   Report

2 ANSWERS

  1. bhaurao eknathrao su...
    scanf() is used to get anything as in input... its can a string,integer etc

    getchar() also takes the input but is used to terminate the program when a certain integer or character is entered  for example

    #include <stdio.h>

    int main ()
    {
      char c;
      puts ("Enter text. Include a dot ('.') in a sentence to exit:");
      do {
        c=getchar();
        putchar (c);
      } while (c != '.');
      return 0;
    }

  2. Guest5206
    getchar uses one character only which is not in the case of scanf.
    getchar can include space,tab,return as its character but in scanf if these incounters next characters are not included and it terminates.
Sign In or Sign Up now to answser this question!

Question Stats

Latest activity: 14 years, 6 month(s) ago.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.