gdb

[GDB] display array(display *input@i)

denishong4.0 2021. 3. 29. 20:36
반응형

예제 코드

file name : test.c

#include <stdio.h>

int main()
{
    char input[100];
    int i = 0;
    scanf("%[^.]s", input);
    
    while(input[i] != '0')
    {   
        printf("%c", input[i]);
        i++;
    }   
    
    return 0;
}

compile 방법

#gcc test.c -o test -g

gdb 실행

#gdb test
#b main
#run
#n
...
scanf함수까지 이동한 후 아래와 같이 임의 문장을 입력한다.
#Test code is.
#display i
#display *input@i
#n
....
이후 next를 입력하면서 값이 변하는 것을 확인하시면 됩니다.

 

 

반응형