标签: program-entry-point

C++返回main

我希望能够从另一个文件返回到main.cpp文件.例如.

// Main.cpp
#include "Globals.h"

int main()
{
    otherFile();
}

// Globals.h

#include <iostream>
#include <stdlib.h>

bool otherFile();

//otherFile.cpp
#include "Globals.h"

bool otherFile() 
{
    // do stuff
    // Here I want to be able to go back to the main.cpp file.
}
Run Code Online (Sandbox Code Playgroud)

对不起,如果我的问题毫无意义

c++ program-entry-point qt-creator

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

如何从main运行实例方法

对不起,我在这里有一个主要的大脑放屁(猜测这是几天的小睡眠让你).如果不将任何内容更改为静态,我如何创建一个将运行此命令的main().

package merger;

import java.util.Random;

public class another {

    public int[] numbers;
    private final static int size = 100;
    private static int maxNumber = 30;
    private final static int limit = 10;
    public int number;
    private boolean Insertion = false;

    public void arraytosort(){
        numbers = new int[size];
        Random number = new Random();
        for (int i=0; i< numbers.length; i++){
            numbers[i] = number.nextInt(maxNumber);
        }
        test(numbers);
    }

    public void test(int[] array){
        this.numbers = array;
        number = array.length;
        mergesort(0,number - 1);
    }

     public void …
Run Code Online (Sandbox Code Playgroud)

java program-entry-point

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

尽管"cin.get();",控制台窗口仍不会停留在屏幕上 或系统("暂停")

我希望每当你运行C++程序时弹出控制台窗口......但是在我的代码中没有发生这种情况.它很快消失了.怎么了?注意:我是C++的新手.

出于某种原因,当我仅使用main()函数来保存所有内容而没有第二个函数时,它可以正常工作,但出于我的任务目的,我无法将所有内容都填入main().

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <cstdio>
using namespace std;

ifstream file("maze.txt");
vector<char> vec(istreambuf_iterator<char>(file), (istreambuf_iterator<char>())); // Imports characters from file
vector<char> path;                      // Declares path as the vector storing the characters from the file
int x = 18;                             // Declaring x as 18 so I can use it with recursion below
char entrance = vec.at(16);             // 'S', the entrance to the maze
char firstsquare = vec.at(17);          // For the …
Run Code Online (Sandbox Code Playgroud)

c++ console program-entry-point

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

如何在数组中交换两个整数,其中我的方法采用两个整数和一个来自main的数组?

我在main中调用我的swap方法,但它不会改变任何东西.我究竟做错了什么?

public static void main(String[] args){


    int mainArr[] = new int[20];

    for(int i = 0; i<mainArr.length; i++){
    swapper(3, 14, mainArr);
    System.out.print(i + mainArr[i] + " ");
    }
}


public static void swapper (int a, int b, int[] mainArr){
    int t = mainArr[a];
    mainArr[a] = mainArr[b];
    mainArr[b] = t;
}
Run Code Online (Sandbox Code Playgroud)

我的代码产生了

0, 1,  2, 3,...19 
Run Code Online (Sandbox Code Playgroud)

以正常的升序,我希望它交换第4和第15个元素.

java arrays methods integer program-entry-point

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

main()函数无法识别

我正在为我正在上课的代码编写代码.我不能发布我的所有代码而不归零我的项目得分,但这里是我的驱动程序的缩写代码:

    #pragma once
    #include <iostream>
    #include <fstream>
    #include <string>
    #include "Stack.h"

    using namespace std;

    namespace jack
    {
        int high(char a)
        {
            // My Code
        };

        bool isSameOrHigher(char top, char cur)
        {
            // My Code
        };

        int main()
        {
            // My Code
        };
    };
Run Code Online (Sandbox Code Playgroud)

由于某种原因,我无法弄清楚何时编译此代码,我收到以下错误:

链接:致命错误LNK1561:必须定义入口点

现在,据我所知,只有当我没有主要功能时才会出现这个错误,你可以看到我确实有这个功能.我已经尝试将此文件中的代码复制到另一个项目中,我已经尝试将我的main函数单独分离到另一个cpp文件中(导致更多错误并且没有修复入口点错误),我尝试过 - 安装Visual C++ express并从头开始.我的老师和我在main()之前检查了这个文件中的所有代码(以及我编写和包含的Stack.h文件中的所有代码),并且没有任何丢失的括号,分号或任何其他标点符号.我不知道还有什么可以尝试的.思考?

c++ program-entry-point compiler-errors entry-point language-lawyer

0
推荐指数
2
解决办法
1055
查看次数

(String []参数)是什么意思?

我将以下代码添加到我在Java中创建的新类中:

public static void main(String[] arguments) {
Run Code Online (Sandbox Code Playgroud)

我理解公共,静态和虚空意味着什么,但是(String[] arguments)意味着什么?

java program-entry-point

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

使用Java的静态方法主要有什么实际区别吗?

如果我有以下Java类:

public class MyClass
{
  ...

  public static void main(String[] args) 
  {
   ...
  }
}
Run Code Online (Sandbox Code Playgroud)

如果我以下面两种方式称呼它,有什么实际区别吗?

[1] new Stock_Image_Scanner().main(null);
[2] Stock_Image_Scanner.main(null);
Run Code Online (Sandbox Code Playgroud)

java static program-entry-point

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

“ main”的返回类型不是“ int”

我正在学习C语言,编写了以下代码:

#include <stdio.h>
void main()
{
  char ch='a';
  printf("%c\n", ch);
}
Run Code Online (Sandbox Code Playgroud)

然后我使用GCC来编译代码,但是我得到一个错误:

return type of 'main' is not 'int' [-Wmain-return-type]
Run Code Online (Sandbox Code Playgroud)

我没有使用任何数据类型int,怎么了?

c program-entry-point

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

TypeError:main()只取1个参数(给定0)

我正在尝试main()在Python 2.7.11中创建一个类文件并运行它,但Python声称我需要传递main()一个参数.

def main(self):
    howManyBadCrops = BadCropsDetector() # My class
    # a bunch of stuff goes here that runs the module....

if __name__ == "__main__":
    main()
Run Code Online (Sandbox Code Playgroud)

为什么会这样?这是我的终端输出:

Traceback (most recent call last):
  File "badCropsDetector.py", line 11, in <module>
    class BadCropsDetector:
  File "badCropsDetector.py", line 66, in BadCropDetector
    main()
TypeError: main() takes exactly 1 argument (0 given)
Run Code Online (Sandbox Code Playgroud)

python program-entry-point typeerror python-2.7

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

什么时候主要返回什么,为什么我得到了主要在linux c中调用的最后一个func的返回值?

这是我在linux中的代码:

#include <stdio.h>
static int tt(void);
static int tt(void)
{
  return 1;
}
int main(int charc,char **charv)
{
  tt();
}
Run Code Online (Sandbox Code Playgroud)

在shell中:

$./a.out
$echo %?
$1
Run Code Online (Sandbox Code Playgroud)

为什么我得到"1"作为结果

c linux program-entry-point

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