美文网首页
[习题3]打印 printf

[习题3]打印 printf

作者: AkuRinbu | 来源:发表于2018-07-05 10:43 被阅读19次

    使用教材

    《“笨办法” 学C语言(Learn C The Hard Way)》
    https://www.jianshu.com/p/b0631208a794

    Makefile

    CFLAGS=-Wall -g
    all: clean ex1 ex3
    
    clean:
        rm  -f  ex1 ex3
    

    ex3.c

    #include <stdio.h>
    
    int main()
    {
        int age;
        int height = 72;
    
        printf("I am %d years old.\n",age);
        printf("I am %d inches tall.\n",height);
    
        return 0;
    }
    

    $

    anno@anno-m:~/Desktop$ make all
    rm  -f  ex1 ex3
    cc     ex1.c   -o ex1
    cc     ex3.c   -o ex3
    anno@anno-m:~/Desktop$ ls
    ex1  ex1.c  ex3  ex3.c  ex3.c~  Makefile  Makefile~
    
    anno@anno-m:~/Desktop$ ./ex3
    I am 0 years old.
    I am 72 inches tall.
    
    • 查看 printfhelp
    anno@anno-m:~$ man 3 printf
    

    printf %d %s

    https://en.cppreference.com/w/c/io/fprintf

    Escape sequences

    https://en.cppreference.com/w/c/language/escape

    Escape sequences.PNG

    ASCII Chart

    https://en.cppreference.com/w/c/language/ascii

    ASCII Chart.PNG

    相关文章

      网友评论

          本文标题:[习题3]打印 printf

          本文链接:https://www.haomeiwen.com/subject/ewbuuftx.html