小编Joe*_*eah的帖子

***没有规则来制作目标'class.cpp',需要`build/.... x86/class.o`停止.Ubuntu中的错误

我试图构建和编译我的程序时遇到此错误.现在我无法打开程序中的所有.cpp文件.

make [2]:*没有规则来制作目标Checker.cpp', needed by 构建/调试/ GNU-Linux-x86/Checker.o'.停止.

有人可以帮我这个吗?我检查了所有在线资源,但我似乎无法找到解决方案.我迫切需要这个解决.感谢给予的任何帮助.

c++ compilation gnu-make

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

activity not found to handle intent

I have a problem regarding my intent. It seems that my app crashes when i select the intent. I found the line of error code due to the stack trace. But i couldn't find anything wrong with it. Hope anyone can help me with this.

This is the java code in line 121:
startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData()));

This is the stack trace:

11-24 16:09:24.634: ERROR/AndroidRuntime(222): Uncaught handler: thread main exiting due to uncaught exception
11-24 16:09:24.834: ERROR/AndroidRuntime(222): android.content.ActivityNotFoundException: No Activity found …
Run Code Online (Sandbox Code Playgroud)

android

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

while循环使用c ++中的计时器

我正在尝试创建一个while循环,当满足字符串条件或计时器条件时,程序将跳出循环并打印出所需的输出.当打印出所需的输出时,输出将包含比较答案之前和之后的时间差.

但是循环并没有像我期望的那样运行.所以任何人都可以帮我弄清楚这段代码的问题在哪里?

以下是我的代码:

void startGame(time_t cd,int gl){
    string guessWord;
    time_t start, end, diff,timeLeft;

    cout << "Scrambled word is " << randomizeWord(gl) << endl;

    while (timeLeft != cd || guessWord.compare(originalWord) == 0)
    {
        start = time(0);
        cout << "You have " << cd << " seconds to guess." << endl;
        cout << "Enter guess : ";
        cin >> guessWord;
        end = time(0);
        diff = end - start;
        //total_time = total_time + diff;
        timeLeft = cd - diff;

        if(guessWord.compare(originalWord) != 0)
        { …
Run Code Online (Sandbox Code Playgroud)

c++ loops while-loop

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

擦除向量中的最后一个元素时的分段错误

我正在尝试使用迭代器擦除向量中的最后一个元素.但是在擦除元素时我遇到了分段错误.

以下是我的代码:

    for (vector<AccDetails>::iterator itr = accDetails.begin(); itr != accDetails.end(); ++itr) {
    if (username == itr->username) {
            itr = accDetails.erase(itr);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的迭代有问题吗?

c++ iterator vector erase

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

使用XOR和位移的字符串的哈希算法

我被赋予这个算法来编写一个哈希函数:

BEGIN Hash(string)
UNSIGNED INTEGER key = 0;
FOR_EACH字符IN字符串
键=((键<< 5)+键)^字符;
END FOR_EACH
RETURN键;
结束哈希

<<操作者参照位左移.在^指异或运算和性质是指该字符的ASCII值.看起来非常简单.

以下是我的代码

unsigned int key = 0;
for (int i = 0; i < data.length(); i++) {
    key = ((key<<5) + key) ^ (int)data[i];
}
return key;
Run Code Online (Sandbox Code Playgroud)

但是,当我实际上从0开始得到一个哈希值时,我一直变得荒谬的正面和负面的巨大数字n.n是用户事先设定的值.我不确定哪里出了问题,但我认为这可能是XOR操作.

任何建议或意见将不胜感激.谢谢!

c++ algorithm hash bit-shift xor

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

插入数据时出现分段错误

我目前正在尝试在一种方法中插入数据,然后将其添加到向量中。由于某种原因,当我到达输入第二组x y的点时,总是会遇到分割错误。

我认为这是导致故障的部分:

    if (shape == "square") {
    for (int i = 0; i < 4; i++) {
        cout << "Please enter x-coordinate of pt." << i+1 << " : ";
        cin >> x;
        cout << "Please enter y-coordinate of pt." << i+1 << " : ";
        cin >> y;

        sq->setName(shape);
        sq->setContainsWarpSpace(type);
        sq->setVertices(i,x,y);

        shapes.push_back(sq);
    }
}
Run Code Online (Sandbox Code Playgroud)

setNamesetContainsWarpSpace是正常的设置方法。

编辑
好吧,我刚刚找到了导致分段错误的行。这是我的setName方法

void ShapeTwoD::setName(string name) {
this->name = name;
} 
Run Code Online (Sandbox Code Playgroud)

EDIT2
根据要求,这是名称和形状的定义。是的,sq是Square类的指针。

内部驱动程序类:

string shape; …
Run Code Online (Sandbox Code Playgroud)

c++ vector

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

使用getMethod()的NullPointerException

这是我提出的上一个问题的延续.从我的Server.class NullPointerException调用public static void main方法时,我似乎得到了.

这是我的Server.class

public static void main(String[] args) throws IOException {
   try {
    //what happens here is that I open up a socket and start listening
    }
    catch (Exception X) {System.out.println(X);}
}
Run Code Online (Sandbox Code Playgroud)

这是我在另一个类中的runServer方法:

public static void runServer() throws Exception{

    File sourceFile = new File("/Users/Joel/NetbeansProjects/FYP/src/ui_v2/Server.java");
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fileMgr = compiler.getStandardFileManager(null, null, null);
    fileMgr.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File("/Users/Joel/NetbeansProjects/FYP/src/ui_v2")));

    compiler.getTask(null, fileMgr, null, null, null, 
            fileMgr.getJavaFileObjectsFromFiles(Arrays.asList(sourceFile)));
    fileMgr.close();

    try {
        Class params[] = {};
        Object paramsObj[] = {}; …
Run Code Online (Sandbox Code Playgroud)

java

-4
推荐指数
1
解决办法
1092
查看次数

标签 统计

c++ ×5

vector ×2

algorithm ×1

android ×1

bit-shift ×1

compilation ×1

erase ×1

gnu-make ×1

hash ×1

iterator ×1

java ×1

loops ×1

while-loop ×1

xor ×1