#include <stdio.h> int main (int argc, char *argv[]) { printf("Welcome to Ascii\n"); char usernumber='1'; while (usernumber != '0') { scanf("%c", &usernumber); printf("ascii: %d \n", usernumber); } return 0; }
Welcome to Ascii k ascii: 107 ascii: 10 l ascii: 108 ascii: 10 m ascii: 109 ascii: 10
while (usernumber != '0') { scanf("%c", &usernumber); if (usernumber != '\x0a') printf("ascii: %d \n", usernumber);
$ cat 2.c #include <stdio.h> int main (int argc, char *argv[]) { printf("Welcome to Ascii\n"); char usernumber='1'; while (usernumber != '0') { scanf("%1[^\n]%*c", &usernumber); printf("ascii: %d \n", usernumber); } return 0; }
printf("Welcome to Ascii\n"); char userchoice='1'; while (userchoice != '0') { scanf(" %c", &userchoice); printf("ascii: %d \n", userchoice); } return 0; }
scanf
#include "stdio.h" char c1 = getchar(); char c2 = getc(stdin); char c3 = fgetc(stdin);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)