S
Samuel.Coddler
Hi,
I'm a newbie programmer. I can't get work the following code.
/*
Objective:
Use a loop to print out all of the input characters until a newline is
found.
*/
#include <stdio.h>
int main (){
/* Declare variable, Assign a initial value x. */
char a = 'x';
while (a != '\n') {
/* Get a user input */
a = getchar();
if (a == '\n'){
/* If the input is a new line, say good bye to user */
printf("\nThat's it for today.\n");
} else {
/* Prints a user input */
printf("%c",a);
}
}
return 1;
}
I'm a newbie programmer. I can't get work the following code.
/*
Objective:
Use a loop to print out all of the input characters until a newline is
found.
*/
#include <stdio.h>
int main (){
/* Declare variable, Assign a initial value x. */
char a = 'x';
while (a != '\n') {
/* Get a user input */
a = getchar();
if (a == '\n'){
/* If the input is a new line, say good bye to user */
printf("\nThat's it for today.\n");
} else {
/* Prints a user input */
printf("%c",a);
}
}
return 1;
}