为什么我的 xCode 编译器输出"lldb"?

Why did my xCode compiler output "lldb"?

本文关键字:lldb 输出 编译器 我的 xCode 为什么      更新时间:2023-10-16
int x = 1;
int main()
{
    int N = 20;
    for (int i=1;i<=N;i++){
        float h = pow(10,-i);
        cout << h << endl;
        cout << r=(sqrt(x+h)-sqrt(x))/h; 
    }
    cout << 1/sqrt(2*x) << endl;
}

我有一个应该输出数字的程序,例如:

0.1, 0.01, 0.001, etc

但它输出的只是

lldb

lldb是什么意思?

我猜你可能正在使用Xcode在Mac上运行这个程序,因为lldb是这种设置的默认调试器。

如果是这种情况,只需键入"run",看看会发生什么。 如果您是初学者,设置命令行环境来构建和运行程序可能会有更好的运气。

代码本身是正确的,这可能意味着您无法在您的环境中正确运行它。我已经复制了您的函数,它就像一个魅力:

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{   
    int N = 20; 
    for (int i=1;i<=N;i++){
        double h = pow(10,-i);
        cout << h << endl;
    }   
}   

使用控制台编译它

$ g++ file.cpp
$ ./a.out
0.1
0.01
0.001
0.0001
1e-05
1e-06
1e-07
1e-08
1e-09
1e-10
1e-11
1e-12
1e-13
1e-14
1e-15
1e-16
1e-17
1e-18
1e-19
1e-20