演習7-2 K&R プログラミング言語C

演習7-2

#include <stdio.h>
#include <ctype.h>

int main(int argc, char *argv[])
{
    int fmtype = 0;
    int c;
    char *(format[2]) = { "0x%06x ", "%03o " };

    while (--argc > 0 && (*++argv)[0] == '-') {
        while ((c = *++argv[0]) != '
#include <stdio.h>
#include <ctype.h>

int main(int argc, char *argv[])
{
    int fmtype = 0;
    int c;
    char *(format[2]) = { "0x%06x ", "%03o " };

    while (--argc > 0 && (*++argv)[0] == '-') {
        while ((c = *++argv[0]) != '\0') {
            switch (c) {
            case 'o':
                fmtype = 1;
                break;
            case 'x':
                fmtype = 0;
                break;
            default:
                fmtype = 0;
                break;
            }
        }
    }

    while ((c = getchar()) != EOF) {
        if (isprint(c) || isspace(c)) {
            putchar(c);
        } else {
            printf(format[fmtype], c);
        }
    }

    return 0;
}
'
) { switch (c) { case 'o': fmtype = 1; break; case 'x': fmtype = 0; break; default: fmtype = 0; break; } } } while ((c = getchar()) != EOF) { if (isprint(c) || isspace(c)) { putchar(c); } else { printf(format[fmtype], c); } } return 0; }
プログラミング言語C 第2版 ANSI規格準拠
B.W. カーニハン D.M. リッチー
共立出版
売り上げランキング: 9726
«
»