+ 3
Help Please, Basic Input and Output C program
#include <stdio.h> int main() { char a[100]; char b; printf("Hello world!\n"); printf("Enter a character : "); b=getchar(); printf("You entered : %c\n", b); printf("Enter a word : "); gets(a); printf("You entered: %s", a); return 0; } So, the purpose of that program is to ask for a character input and then display the character. After that, the program then prompt the user to input a word and displayed them. Unfortunately, it doesn't work the way is supposed to. What went wrong here ?
4 ответов
+ 9
Sololearn IDE haven't facility to type input one by one . You have type it all just for once using space and new line
+ 7
Interactive input does not work on code playground for non web codes. You need to enter all inputs at once, separated by newlines.
+ 1
Try having the input for the word first and the input of the character second.
#include <stdio.h>
int main() {
char a[100];
char b;
printf("Hello world!\n");
printf("Enter a word : ");
gets(a);
printf("You enterded : %s\n", a);
printf("Enter a character : ");
b=getchar();
printf("You enterded : %c\n ", b);
return 0;
}