I dont know how but i need to prompt to input 2 seperate characters and output that 2 characters but it doesnt work.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I dont know how but i need to prompt to input 2 seperate characters and output that 2 characters but it doesnt work..

getc or getchar https://code.sololearn.com/cI0OQhAFkqXH/?ref=app

22nd Nov 2021, 1:19 AM
Christian Jay Medallo
Christian Jay Medallo - avatar
8 Answers
+ 2
Call getchar() once again after reading value for <a>, but without assigning its return value to anything. This extra call is meant to consume the line break '\n' character that was read following input for <a>.
22nd Nov 2021, 1:32 AM
Ipang
+ 2
char a = getchar(); getchar(); // call getchar() again to consume the line break character that came from pressing {Enter} key or whitespace from {Spacebar} char b = getchar();
22nd Nov 2021, 1:48 AM
Ipang
+ 1
Are you needing to output as such Input chat a = 'a'; char b = 'b'; Output: ab Or a b and are they to be printed or returned?
22nd Nov 2021, 1:31 AM
William Owens
William Owens - avatar
+ 1
I dont get what you mean ipang.. Sorry
22nd Nov 2021, 1:42 AM
Christian Jay Medallo
Christian Jay Medallo - avatar
+ 1
#include <stdio.h> int main(void){ char a, b; a = getc(stdin); b = getc(stdin); printf("%c%c", a,b); } add in any printf messages you want.
22nd Nov 2021, 1:47 AM
William Owens
William Owens - avatar
+ 1
Thanks guys for the help.. Im good now
22nd Nov 2021, 1:52 AM
Christian Jay Medallo
Christian Jay Medallo - avatar
0
Yeah i need to input 2 different chars and output that 2 characters that is inputted
22nd Nov 2021, 1:40 AM
Christian Jay Medallo
Christian Jay Medallo - avatar
0
How can i do project for the fourth trial and make it do completed
23rd Nov 2021, 1:02 PM
Viji .S