Visual studio调试和在linux gdb调试的尝试

 

                                    Visual studio调试: 定位代码    缩小调试范围    打断点     不断继续run    查看需要变量值与自己预期结果  判断哪里问题

 

 

#include "stdafx.h"
#include <stdio.h>
#include <string.h>

const char* str[] = { "Hello","abc","applef","man","C程序设计","指针数组","1","2","3" };
const char* pdest = "指针数组";


int main()
{
    int i;
    int ret = -1;
    const char * * p = str;
    for (i = 0; i < sizeof(str) / sizeof(char*); i++)
    {

#if 0 
        if (strcmp(*p++, pdest) == 0)
        {
            printf("we are found dest\n");
            break;
        }
#endif 


        p = p + i;  // 这样是错误的   p的变化太大 指针越界



    }
    printf("\n");        
    printf("i = %d\n", sizeof(str) / sizeof(char*));

    while (1);

    return 0;
}



  查看变量的值是:     添加监视  就知道变量的值什么回事