这段代码有什么问题,gcc不会将其转换为.exe

What is wrong with this piece of code that gcc will not convert it to .exe

本文关键字:gcc exe 转换 问题 段代码 代码 什么      更新时间:2023-10-16

我似乎找不到这个问题的答案,我想是因为它太开放了。

我目前正在学习c++与一个傻瓜的书。这本书有点旧了(2001年),但仍然很有帮助。我正忙着处理这段代码,我试着用gcc -o conversion conversion.cpp行在cmd中转换它(我的文件叫做conversion)。

当我试图转换它时,它在长文本的末尾说:

failed: invalid operation
collect2.exe: error: ld returned 1 exit status

这是我的代码:

#include <stdio.h>
#include <iostream>
    using namespace std;
    int main(int arg, char* pszArgs[])
    {   
        int loopCount;
        cout << "Enter the amount of loops: ";
        cin >> loopCount;
        while (loopCount > 0)
        {
            loopCount = loopCount - 1;
            cout << "Still " << loopCount << " to go/n";
        return 0;
        }
        }

请帮忙,我想知道出了什么问题。我到处都找不到……

g++编译c++程序,不能用gcc