answersLogoWhite

0


Best Answer

If you are referring to getchar(), it returns a single character as an 'int'.

'scanf' allows the user to input many different types of variables, and converts them accordingly using a format specified by the user.

If you type 'man getchar' and 'man scanf' you will get additional information on how to use them.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

/*No of the repetition character in a string */ #include #include void main() { char ch,str[30]; int i=0,count=0; clrscr(); printf("\n\t Enter your name : "); scanf("%s",str); printf("\n\t Enter character : "); ch=getche(); for(i=0;str[i]!='\0';i++) { if(str[i]==ch) count++; } printf("\n\t No of the repetition character %c in a string is %d",ch,count); getch(); }

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

In the C and C++ runtime library, getc(FILE *stream) reads a single character from a stream and increments the associated file pointer (if there is one) to point to the next character, while getch() reads a single character from the console without echoing it. In the case of getc, getc(stdin) is the same as getchar().

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

int getchar(void) is the same as getc(stdin) - it returns a single unsigned character (0-255) as an int from the "stdin" stream. It requires the stdio.h library and is therefore available across multiple platforms.

int getch(void) is used with conio.h and curses.h and does something similar. However, if using curses.h, "delay mode" and the setting of "cbreak" determine whether it waits for a character or not plus how it reacts to that situation.

When used from conio.h, it will wait until a character is available and then return it. To detect if a character is available, use the kbhit() function.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Echoing. (Next time you might want to try and use the built-in help system.)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between getcher and getch statements in C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can you replace getch of C programming in Linux without using iostream header?

There is a 'getch' in 'conio.h' which has nothing to do with 'iostream'.


Why getch function has semicolen?

Without the semi-colon, getch is just an expression, not a statement.


What is the purpose of getch()?

getch() is a way to get a user-inputted character. It can be used to hold program execution, but the "holding" is simply a side-effect of its primary purpose, which is to wait until the user enters a character. getch() and getchar() are used to read a character from screen.


What is difference between getchar and getch?

Both getch() and getche() are used to read single character there is very little difference -getch() doesn't display output to screen if used without lvalue -getche() display output to screen even if used without lvalue following example will clear this..... 1. main() { getch(); } 2. main() { getche(); } after running above programs............... when you press any key, you'll exit from output screen verify the output by pressing alt+F5 1. will not show anything 2.will show the key you were pressed...... hope you get it............. __________________________________________________________________ getch() - get character from screen without echo and compiler didn't wait for another key. getche() - get character from screen and compiler didn't wait for another key getchar() - get character from screen and compiler wait for another key and moreover it returns a integer value i.e. the ASCII(American Standard Code for Information exchange) which we can use where ever we want.for example:- mostly in encryption. In this the major concept is of echoing and it is nothing but when we enter anything through keyboard and if it is coming back on the screen (even if to show that what we are entering ) that's called echoing. and this is what makes difference in getch() and getche()


How to write printf statements for print 1.234 in a 9-digit field with preceding zeros?

#include<stdio.h> #include<conio.h> void main() { char b=0; float a; clrscr(); a=1.234; printf("\n%d%d%d%d%.3f",b,b,b,b,a); getch(); }

Related questions

Purpose of getch?

The purpose of getch() is to input a single character from the input stream.


Can you replace getch of C programming in Linux without using iostream header?

There is a 'getch' in 'conio.h' which has nothing to do with 'iostream'.


Why getch function has semicolen?

Without the semi-colon, getch is just an expression, not a statement.


Return value of getch?

char


How you use getch in ubuntu Linux?

Quote taken from The Unix and Linux Forum: getch() is an ancient DOS syscall from even older versions of Borland Turbo C. Mostly nothing has it these days. Unquote. Search Google with "getch" and have a look through the webpages on the subject. There are no manual (man) pages for getch - I'm using Ubuntu 12.04.


What is the purpose of getch()?

getch() is a way to get a user-inputted character. It can be used to hold program execution, but the "holding" is simply a side-effect of its primary purpose, which is to wait until the user enters a character. getch() and getchar() are used to read a character from screen.


What use getch function in c language?

Gets one character (or keystroke) without buffering or echoing; beware: getch is not part of the standard library.


What is the use of getch in C programming?

We use getch() function to hold the screen so that we can see the output but in real it is use to take a input of a character from the console window. Read this out -


What is difference between getchar and getch?

Both getch() and getche() are used to read single character there is very little difference -getch() doesn't display output to screen if used without lvalue -getche() display output to screen even if used without lvalue following example will clear this..... 1. main() { getch(); } 2. main() { getche(); } after running above programs............... when you press any key, you'll exit from output screen verify the output by pressing alt+F5 1. will not show anything 2.will show the key you were pressed...... hope you get it............. __________________________________________________________________ getch() - get character from screen without echo and compiler didn't wait for another key. getche() - get character from screen and compiler didn't wait for another key getchar() - get character from screen and compiler wait for another key and moreover it returns a integer value i.e. the ASCII(American Standard Code for Information exchange) which we can use where ever we want.for example:- mostly in encryption. In this the major concept is of echoing and it is nothing but when we enter anything through keyboard and if it is coming back on the screen (even if to show that what we are entering ) that's called echoing. and this is what makes difference in getch() and getche()


How to write printf statements for print 1.234 in a 9-digit field with preceding zeros?

#include<stdio.h> #include<conio.h> void main() { char b=0; float a; clrscr(); a=1.234; printf("\n%d%d%d%d%.3f",b,b,b,b,a); getch(); }


What is the function key that is used to display the result in the output screen?

getch();


Give an code for getch?

#include <conio.h> #include <stdio.h> int mygetch (void) { int x; x= getch (); if (x==0) x= 1000+getch(); return x; } int main (void) { int key; key = mygetch (); if (key==1059) printf ("F1\n"); else printf ("%d\n", key); return 0; }