相关疑难解决方法(0)

跟踪变量自动变化

我正在调试一个C程序(Linux中的GCC和GDB以及Windows中的Visual Studio),它在两种不同的体系结构上提供不同的结果.我想通过跟踪存储在变量中的值的更改来比较每个体系结构的执行,以便找到差异.

file main.c, line 234. Variable A changes from 34 to 23
file main.c, line 236. Variable B changes from 0 to 2
.....
etc.

是否可以指示编译器检测此效果,而无需手动乱丢源printf语句?

c compiler-construction debugging

6
推荐指数
1
解决办法
2222
查看次数

如何在C++中打印变量的名称?

可能重复:
在C中获取变量名的编程方式?

我在这里发布之前已经检查了一些博客.我试过以下片段......

int a=21;

int main()
{
   cout<<#a<<a<<endl;
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

我在ubuntu 10.04上使用g ++编译器.我收到以下错误:

sample.cpp:17: error: stray ‘#’ in program. 
Run Code Online (Sandbox Code Playgroud)

请建议我如何打印变量名称.

c++

6
推荐指数
1
解决办法
1万
查看次数

变量名,C 中运行时的函数参数

是否可以在 C 程序中在运行时知道函数参数和变量的名称类型?例如,如果我有一个函数:

int abc(int x, float y , somestruct z ){
    char a;
    int b ;
}
Run Code Online (Sandbox Code Playgroud)

我可以知道在这个函数内部abc(),参数和变量的名称是什么,在这种情况下它的x, y, z, ab它们的类型是int, float, somestruct, char, int

说是否还有另一个功能:

float some_func(specialstruct my_struct, int index){

} 
Run Code Online (Sandbox Code Playgroud)

我应该知道参数 name 是my_structindex类型是specialstruct, int

我在运行时需要这些信息?

我可以访问基指针和返回地址,是否可以使用上述指针获取所需信息。

我能够使用返回地址和dladdr()函数提取函数名称。

我明白了GDB,所以应该可以提取这些信息?

c linux gdb bfd dladdr

6
推荐指数
1
解决办法
488
查看次数

如何用c中的值打印整数的名称

我们如何在输出中打印最年轻的名字?我想计算最年轻的人.

那是我的代码:

    #include <stdio.h>
    #include <conio.h>
    int main() {
    int john;
    int ahmad;
    int saleem;

    printf("Enter the age of john,ahamd, saleem simaltanoeusly\n");
    scanf_s("%d\n%d\n%d", &john, &ahmad, &saleem);


    int youngest = john;
    if (john > ahmad) 
        youngest = ahmad;
    if (ahmad > saleem)
        youngest = saleem;

    printf("youngest of you is %d", youngest);

    _getch();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c int

0
推荐指数
1
解决办法
678
查看次数

标签 统计

c ×3

bfd ×1

c++ ×1

compiler-construction ×1

debugging ×1

dladdr ×1

gdb ×1

int ×1

linux ×1