0基礎學習ios開發筆記第一天,ios筆記第一天

來源:互聯網
上載者:User

0基礎學習ios開發筆記第一天,ios筆記第一天
Ios操作介面操作快速鍵

command + c 複製

command+v 粘貼

command +a 全選

command +s 儲存

command +z 撤銷

command +x  剪下

command +space  IME的切換

command +<—(退格鍵)   刪除游標所在行,游標前的所有內容

option鍵(ios)--alt(windows)鍵

command在Windows鍵盤中就是windows鍵

Linux命令cd

cd:change directory 切換目錄

liuzw@ubuntu:~/sunjie$ cd cliuzw@ubuntu:~/sunjie/c$ 

 

cd  ~ 或者直接輸入cd,是切換到目前使用者的主目錄

liuzw@ubuntu:~/sunjie/c$ cd liuzw@ubuntu:~$

 

cd  -  撤銷上一次的cd操作

liuzw@ubuntu:~/sunjie$ cd cliuzw@ubuntu:~/sunjie/c$ cd liuzw@ubuntu:~$ cd -/home/liuzw/sunjie/cliuzw@ubuntu:~/sunjie/c$ 

 

cd / 回到根目錄

cd .. 回到父目錄

liuzw@ubuntu:~/sunjie/c$ cd ..liuzw@ubuntu:~/sunjie$ 

 

pwd:print workdirectory查看當前工作路徑

 

liuzw@ubuntu:~/sunjie$ pwd/home/liuzw/sunjie
ls: list source 查看當前工作路徑下的資源,包括檔案及目錄

 

ls –a(all) 查看所有資源,包括隱藏的

 

ls –l(list one file per line)

 

紅色圈住的第一列表示資源類型,其中的d表示目錄,-表示檔案

紅色圈住的第二列表示佔用磁碟空間大小

mkdir : make directory 建立目錄

 

mkdir –p 當父目錄不存在時,就建立父目錄,而不是報錯

 

touch 一般用來建立空檔案echo 回顯資料 輸出變數

 

$? 表示上一次命令的執行結果,0表示執行正確,其他的表示錯誤,如示

 

cp :copy

拷貝檔案

 

拷貝目錄

 

 

cat 顯示檔案內容,只能看檔案,不能看目錄

 

 

 

 

cat –n 顯示時加行號

 

C語言 

電腦只認識1和0,程式設計語言的層級如下:

機器語言

組合語言

進階語言(c語言)

1001,0010,0010,1111

mov  2 f

while   if  int

C語言的編譯過程

編譯:實質就是翻譯。常用的編譯器如:gcc

可執行檔是運行時環境和一些.o結尾的檔案的集合。將我自己目標檔案和這些檔案連結以後,形成可執行檔檔案。

目標檔案是二進位機器碼檔案,可執行檔也是二進位的機器碼檔案,但是目標檔案不能在機器上運行,必須與運行環境等連結才可運行。而可執行檔可以在機器上運行。

編寫我的第一個c程式,hello.c他hello.h

hello.h檔案內容如下:

#define HELLO "helloworld"

Hello.c檔案內容如下

#include <stdio.h>#include "hello.h"int main(void){    printf(HELLO);    return 0;}

整個編譯階段分為四步:

第一步:預先處理,hello.c轉變為hello.i,一般為隱式執行

預先處理命令:gcc -E hello.c -o hello.i,產生預先處理檔案簡略如下:

extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));

extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;

extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));

# 943 "/usr/include/stdio.h" 3 4

# 2 "hello.c" 2

# 1 "hello.h" 1

# 3 "hello.c" 2

int main(void)

{

    printf("helloworld");

    return 0;

}

在預先處理階段,宏HELLO被替換為實際內容

第二步:彙編階段,將C語言檔案轉換為組合語言檔案,也就是hello.i轉變為hello.s

命令:gcc -S hello.i -o hello.s

hello.s檔案內容如下

    .file   "hello.c"    .section   .rodata.LC0:    .string "helloworld"    .text    .globl  main    .type   main, @functionmain:.LFB0:    .cfi_startproc    pushq   %rbp    .cfi_def_cfa_offset 16    .cfi_offset 6, -16    movq    %rsp, %rbp    .cfi_def_cfa_register 6    movl    $.LC0, %edi    movl    $0, %eax    call    printf    movl    $0, %eax    popq    %rbp    .cfi_def_cfa 7, 8    ret    .cfi_endproc.LFE0:    .size   main, .-main    .ident  "GCC: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4"    .section   .note.GNU-stack,"",@progbits

第三步:將組合語言編譯成對應的機器語言(二進位格式),也就是hello.s轉換為hello.o

命令:

gcc -c hello.s -o hello.o

使用命令

objdump -d hello.o

反組譯碼hello.o檔案內容如下:

hello.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <main>:

   0: 55                   push   %rbp

   1: 48 89 e5                mov    %rsp,%rbp

   4: bf 00 00 00 00         mov    $0x0,%edi

   9: b8 00 00 00 00         mov    $0x0,%eax

   e: e8 00 00 00 00         callq  13 <main+0x13>

  13: b8 00 00 00 00         mov    $0x0,%eax

  18: 5d                   pop    %rbp

  19: c3                   retq

第四步:將hello.o檔案與運行環境連結,形成可執行檔

命令:

gcc hello.o -o hello

查看hello檔案內容,命令objdump –d hello反組譯碼查看

000000000040052d <main>:

  40052d: 55                     push   %rbp

  40052e: 48 89 e5               mov    %rsp,%rbp

  400531: bf d4 05 40 00         mov    $0x4005d4,%edi

  400536: b8 00 00 00 00         mov    $0x0,%eax

  40053b: e8 d0 fe ff ff         callq  400410 <printf@plt>

  400540: b8 00 00 00 00         mov    $0x0,%eax

  400545: 5d                     pop    %rbp

  400546: c3                     retq  

  400547: 66 0f 1f 84 00 00 00   nopw   0x0(%rax,%rax,1)

  40054e: 00 00

以上為連結後的main函數,注意與未連結的區別:

0000000000000000 <main>:

   0:     55                   push   %rbp

   1:     48 89 e5                  mov    %rsp,%rbp

   4:     bf 00 00 00 00           mov    $0x0,%edi

   9:     b8 00 00 00 00           mov    $0x0,%eax

   e:     e8 00 00 00 00           callq  13 <main+0x13>

  13:     b8 00 00 00 00           mov    $0x0,%eax

  18:     5d                   pop    %rbp

  19:     c3                   retq

執行檔案,命令./hello

如果把hello.c程式中的return 0 去掉的話,傳回值就不一定為0

liuzw@ubuntu:~/sunjie/c$ ./a.out

helloworldliuzw@ubuntu:~/sunjie/c$ echo $?

10

總結:以上所有具體的編譯過程可直接執行如下命令,直接形成可執行檔a.out

,也可加-o hello

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.