Advertisement
cd62131

AsciiToDecimal

Mar 3rd, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int atodec(void) {
  4.   char in[80];
  5.   int i, len;
  6.   printf("文字列を入力> ");
  7.   fgets(in, 80, stdin);
  8.   in[strlen(in) - 1] = '\0'; // remove new line
  9.   len = strlen(in);
  10.   for (i = 0; i < len; i++) {
  11.     printf("%d", in[i]);
  12.     if (i < len - 1) printf("_");
  13.   }
  14.   puts("");
  15.   return len;
  16. }
  17. int main(void) {
  18.   int len = atodec();
  19.   printf("文字列は、%d 文字でした。", len);
  20.   return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement