dereference

    3熱度

    3回答

    我在C中學習指針,但我對這個例子有點困惑。以下三個printf()陳述中指針的指針邏輯是什麼?這些是什麼:*(char*)ptr,*(int*)ptr,(char*)ptr+2,到底在幹什麼? #include<stdio.h> int main() { void *ptr; char ch=74, *cp="CS107"; int j=65; ptr=

    0熱度

    2回答

    考慮下面的代碼: int main() { int* p = new int(3); p+=4; std::cout<<*p<<std::endl; } 我的編譯器(的Visual Studio 2012)打印:-7514522142 INT這種情況。 因此,我們可以以某種方式推導出輸出,並且此代碼是否合法?

    5熱度

    1回答

    嘗試爲自定義類型實現Debug特徵我偶然發現了Vec<T>的實現。我很難理解它是如何工作的。 實現是這樣的: impl<T: fmt::Debug> fmt::Debug for Vec<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) }

    1熱度

    1回答

    我試圖在由char *表示的句子中將大寫更改爲小寫。 我得到一個錯誤:當我使指針解引用時出現訪問衝突。 // Uppercase to lowercase char *str = "My sentence"; *str = 'm';

    0熱度

    2回答

    我想創建一個程序,按升序排序五個整數。我從來沒有遇到一個解除錯誤的錯誤,所以我很好奇我做錯了什麼。 Scanner input = new Scanner(System.in); int[] a = new int[5]; for (int i = 0; i < 5; i++) { System.out.println("Please enter inte

    -1熱度

    1回答

    我有一個練習,我必須創建一定數量的pthreads去噪聲圖像,但我遇到了與指針有關的問題。每個線程獲取input_image,但是所有線程都需要能夠寫入相同的output_image。以下是相關的部分。 struct task{ int start_row, stop_row, window_size; image_matrix input_image; image_

    0熱度

    1回答

    時,我有一個簡單的模塊,像這樣: #define MODULE #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> int init_module(void) { struct inode { int i_ino; }; struct dentr

    2熱度

    2回答

    TL; DR 是[memloc]是指值還是地址?如果它是指任何一個,那麼爲什麼它的值都是和的地址? (見下面的代碼,行4和5) 全部問題... 對不起,長的問題。 我很困惑在NASM標籤解引用。以這個例子: 01| section .text 02| ; exiting the program with exit code "15" 03| 04| mov [memloc], 15 ; m

    5熱度

    1回答

    所以,我最近感興趣的是編譯器(gcc (GCC) 4.8.3是否是有問題的)在優化指針和指針方面的表現。 最初我創建了一個簡單的整數和一個整數指針,並且實現了 操作,所以我可以打印出來。正如預期的那樣,硬編碼的所有操作 都是通過取消引用指針來優化的。 call __main leaq .LC0(%rip), %rcx movl $1, %edx call printf 甚至創建一個函數,

    0熱度

    1回答

    我希望自己通過這個獨立研究http://security.cs.rpi.edu/~candej2/syllabus.pdf自己學習利用寫入的一些基本知識,並且實際上可以從頭開始編寫漏洞利用。所以...我在看http://security.cs.rpi.edu/~candej2/kernel/trivial_sploit.c 和http://security.cs.rpi.edu/~candej2/