我正在使用MVisualC++ 2010,当我尝试取消定义"main"时,没有结果,控制台像往常一样启动.我期待一些丢失的入口点错误或其他什么.这是为什么?
#undef main
int main()
{
}
Run Code Online (Sandbox Code Playgroud) python脚本有什么问题?
码:
import os
import shutil
import getpass
os.mkdir("C:\\dtmp")
shutil.copy("C:\\path\\to\\bb-freeze-script.py","C:\\dtmp")
os.chdir("C:\\dtmp")
shutil.copy("C:\\path\\to\\main.py","C:\\dtmp")
os.system("python bb-freeze-script.py main.py")
os.mkdir("C:\\Program Files\\Directories v0.6")
os.chdir("C:\\")
shutil.rmtree("C:\\dtmp")
print getpass.getuser()
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "bb-freeze-script.py", line 8, in <module>
load_entry_point('bbfreeze==0.97.3', 'console_scripts', 'bb-freeze')()
File "C:\Python27\lib\site-packages\bbfreeze-0.97.3-py2.7-win32.egg\bbfreeze\__init__.py", line 24, in main
f.addScript(x)
File "C:\Python27\lib\site-packages\bbfreeze-0.97.3-py2.7-win32.egg\bbfreeze\freezer.py", line 410, in addScript
s = self.mf.run_script(path)
File "C:\Python27\lib\site-packages\bbfreeze-0.97.3-py2.7-win32.egg\bbfreeze\modulegraph\modulegraph.py", line 241, in run_script
co = compile(file(pathname, READ_MODE).read()+'\n', pathname, 'exec')
File "C:\dtmp\main.py", line 14
^
IndentationError: expected an indented block
Run Code Online (Sandbox Code Playgroud)
操作系统 - Windows XP
我正在使用Fedora,我遇到了一些让javac工作的问题(我终于成功了一个别名).但现在我无法执行我的java代码.我在标题中收到错误.这是包含main方法的类:
public class test
{
public static void main(String args)
{
int res[]= {4,2,6};
res=Trieur.tri(res);
for(int i: res)
System.out.println(i);
}
}
Run Code Online (Sandbox Code Playgroud)
我在这个论坛上一直在尝试很多解决方案,但似乎都没有效果.该程序成功编译.你能帮我么?
我试图为Deitel的C#2010编译程序员的代码.我把它完全复制出了书,但它仍然找不到main,尽管我在其中一个类中声明了它.以下是两个类:
对于GradeBookTest:
// Fig. 4.2: GradeBookTest.cs
// Create a GradeBook object and call its DisplayMessage method.
public class GradeBookTest
{
// Main method begins program execution
public static void Main(string[] args)
{
// create a GradeBook object and assign it to myGradeBook
GradeBook myGradeBook = new GradeBook();
// call myGradeBook's DisplayMessage method
myGradeBook.DisplayMessage();
} // end Main
} // end class GradeBookTest
Run Code Online (Sandbox Code Playgroud)
现在为GradeBook类:
// Fig. 4.1: GradeBook.cs
// Class declaration with one method.
using System;
public class GradeBook
{
// …Run Code Online (Sandbox Code Playgroud) 我在运行以下代码时Error: Could not find or load main class遇到问题,它说但是我在代码中明显有一个主要内容......
package abc;
import java.io.IOException;
import javax.swing.JOptionPane;
// As its name implies, this is what is driving the program, asking for input, giving output, etc.
public class driver
{
@SuppressWarnings("unused")
public static void main(String args[]) throws IOException // a main that throws an exception... hmmm... yes it's odd, but apparently not illegal
{
....}
private static void processTransaction(String trans, Customer[] customers) throws IOException // this is the function that processes the …Run Code Online (Sandbox Code Playgroud) 为什么此代码打印1而不是5
码:
main(int x=5) //this defn. is written intentionally to chec weather main accepts
expression or not.
{
printf("%d",x);
}
Run Code Online (Sandbox Code Playgroud)
编译使用:minGW 3.2
编辑
我的观点是天气x=5执行与否.如果没有那么为什么我没有得到任何错误或警告.
看来这是return status code从你的角度来看的一种方式main.但我想知道这int是怎么回事?我在eclipse上尝试过,但是我没有在控制台上看到它.我怎么得到的status code
public static void main(String[] args){
int status = 123;
System.exit(status);
}
Run Code Online (Sandbox Code Playgroud) 我想知道当我使用main函数的返回值时会发生什么.
我发现如果我从main(它应该是退出状态)返回一个数组变量并在shell中打印退出状态,输出总是56.我想知道为什么?
C程序:
int* main(void) {
static int x[3];
x[0]=89;
x[1]=15;
x[2]=10;
return x;
}
Run Code Online (Sandbox Code Playgroud)
我按如下方式测试:
gcc array_return.c -o array_return
./array_return
echo $?
Run Code Online (Sandbox Code Playgroud)
56即使我更改数组的大小或更改其中的数字,输出也始终是.这个数字56是什么意思?
对于我的类,我需要创建一个在运行时接受多个参数的函数:
void main(int x, int y, int generation, char *layout[20])
Run Code Online (Sandbox Code Playgroud)
但是,当程序以我对这些变量的输入运行时,信息不会存储在调试过程中
run 3 3 3 Test_Round
print x // returns 5
print y // returns -8779
Run Code Online (Sandbox Code Playgroud)
如何将多个参数传递给main函数,以便main识别我给它的参数?
感谢大家!我只是使用argv [1]等来获取我需要的正确数据!
问题是,当我打开“ cmd.exe”并转到名为chesschallenge6的目录以输入“ sbt”命令并随后“运行”时,它不起作用。我收到一条错误消息,提示未指定主类。我检查了主类名称是否与它的文件名相同,甚至尝试了“对象ChessChallenge6扩展应用程序”,但仍然无法正常工作。解决方案很简单,但我看不到。
??? _chesschallenge6
??? _project
??? _target
??? _src
??? _test
??? _main
??? _algorithm
??? _model
??? ChessChallenge6.scala
Run Code Online (Sandbox Code Playgroud) java ×3
c ×2
c++ ×2
c# ×1
class ×1
exception ×1
exit ×1
exitstatus ×1
indentation ×1
oop ×1
parameters ×1
python ×1
sbt ×1
scala ×1
shell ×1
system.exit ×1
undef ×1
windows-xp ×1