标签: runtime-error

堆栈链接错误问题

编译器在运行程序时给出了这些错误 -

  "Stack<int>::push(int&)", referenced from:
      _main in main.o
  "Stack<int>::~Stack()", referenced from:
      _main in main.o
      _main in main.o
  "Stack<int>::Stack()", referenced from:
      _main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

编译时我没有错误.

代码如下 -

/*
 *  Stack.h
 *  Stack
 *
 *  Created by Sterling McLeod on 2/1/11.
 *  Copyright 2011 University of North Carolina at Charlotte. All rights reserved.
 *
 */
#ifndef STACK_H
#define STACK_H

#include <exception>

template<typename T>
class Stack {

public:


    class EmptyTreeException : public std::exception …
Run Code Online (Sandbox Code Playgroud)

c++ stack runtime-error g++ linker-errors

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

线程"main"中的Java异常java.lang.ArrayIndexOutOfBoundsException

在学校的项目上工作,当我尝试输入阵列的学生数量时,我收到错误.错误是

例外在线程"主" java.lang.ArrayIndexOutOfBoundsException:-1
在Project1.enterStudents(Project1.java23)
在Project1.mainMenu(Project1.java59)
在Project1.enterStudents(Project1.java7)

我在下面写的代码一如既往的任何帮助表示赞赏.

import java.util.Scanner;

public class Project1{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
Project1 project1 = new Project1();
project1.mainMenu();


}//main

int numOfStudents;
Student[] students = new Student[numOfStudents];

public void enterStudents(){
    Scanner input = new Scanner(System.in);
    System.out.println("Enter number of students");
    numOfStudents = input.nextInt();
    int i;
    for(i = 0; i <= numOfStudents - 1; i++){
        i--;
        System.out.println("Enter student's ID: ");
        students[i].getId();
        System.out.println("Enter student's first name: ");
        students[i].getFirst();
        System.out.println("Enter student's last name: ");
        students[i].getLast(); …
Run Code Online (Sandbox Code Playgroud)

java arrays runtime-error indexoutofboundsexception

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

C++错误消息:指针无效

我有一个函数将字符串附加到另一个字符串:

char* strjoin(char* str1,const char* str2) {
  long len1 = strlen(str1);
  long len2 = strlen(str2);
  char* result = (char*)malloc(len1+len2+1);

  memcpy(result,str1,len1+1);
  memcpy(result+len1,str2,len2+1);

  free(str1); <--------- program crashes here with error: invalid pointer
  return result;
}
Run Code Online (Sandbox Code Playgroud)

调用上面函数的代码是这样的:

char* str = "John";
str = strjoin(str,"\x20");
str = strjoin(str,"Doe");
Run Code Online (Sandbox Code Playgroud)

在上面的函数strjoin中,我为新字符串分配内存,所以我释放旧的str1.为什么str1无效指针?

c++ pointers runtime-error memcpy

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

为什么JavaScript wrapInner会抛出错误?

我有一个带有以下代码的Firefox插件:

$("table > tbody > tr > td[width='600']").wrapInner("<div id='content_cont' />");
Run Code Online (Sandbox Code Playgroud)

这行代码执行,但它之后的所有行都不执行.它会在Firefox错误控制台中抛出一个错误,该错误的代码超过500KB.

码:

An exception occurred.
Traceback (most recent call last):
  File "resource://jid0-ib8arkgejpxo7qidkuieut5rquk-at-jetpack/flvs-educator-release-version/data/redesign.js", line 49, in 
    $("table > tbody > tr > td[width='600']").wrapInner("<div id='content_cont' />");
  File "resource://jid0-ib8arkgejpxo7qidkuieut5rquk-at-jetpack/flvs-educator-release-version/data/jquery.js", line 2, in .wrapInner
    (function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s)...<tons of meaningless code>...&define("jquery",[],function(){return p})})(window);
ReferenceError: Begin is not defined
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚为什么这样做.语法错了吗?

javascript jquery runtime-error firefox-addon

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

调用未定义的函数错误,甚至定义了函数

我有一个会话安全的文件"admin.php".这是登录后的默认页面.这引发了以下错误:

致命错误:在第14行的C:\ xampp\htdocs\cd-website\cms\admin.php中调用未定义的函数listPages()

<?php
/*
* initialize session for admin
*/
session_start();

if(isset($_SESSION['admin_user']))
{
    require_once '../cms/config.php';

    $action = isset($_POST['action']) ? $_POST['action'] : '';

    if ($action == null)
    {
        listPages();
        exit;
    }

    /*
     * using switch for choosing function
     */
    switch($action)
    {
        case 'ManagePages':
            ManagePages();
            break;
        case 'listUsers':
            listUsers();
            break;
        case 'orderList':
            listOrders();
            break;
        case 'listBanner':
            listBanners();
            break;
        case 'NewsletterUser':
            NewsletterUsers();
            break;
        case 'Newsletter':
            Newsletter();
            break;
        case 'listQuestion':
            listquestions();
            break;
        case 'testinomial':
            listTesti();
            break;
        default:
            listPages();
    }

    /*
     * different function …
Run Code Online (Sandbox Code Playgroud)

php runtime-error

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

fork()之后,child没有执行

int status=0;
int PID = fork();
if(PID == 0)
{
   char *path = strcat(pathToken,strcat("/",command));
   printf("path: %s\n",path);
   execl(path,command,"-l",NULL);
}
else if(PID>0)
{
   printf("pid: %d. ",PID);
   printf("I'm parent process\n");
   wait(&status);
}
Run Code Online (Sandbox Code Playgroud)

输出:

pid: 20027. I'm parent process
Run Code Online (Sandbox Code Playgroud)

为什么不进入if(PID==0)?

c linux fork runtime-error exec

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

编译或运行时在java中获取错误

我是java新手,我从wikibooks下载了一个pdf文档,在尝试运行程序时遇到以下错误:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Distance.main(Distance.java:7)
Run Code Online (Sandbox Code Playgroud)

这是我试图运行的代码:

public class Distance
{
    private java.awt.Point point0, point1;
    public Distance(int x0, int y0, int x1, int y1)
    {
        point0 = new java.awt.Point(x0, y0);
        point1 = new java.awt.Point(x1, y1);
    }

    public void printDistance()
    {
        System.out.println("Distance between " + point0 + " and " + point1
            + " is " + point0.distance(point1));
    }

    public static void main(String[] args)
    {
        Distance dist = new Distance(
        intValue(args[0]), intValue(args[1]),
        intValue(args[2]), intValue(args[3]));
        dist.printDistance();
    }

    private static …
Run Code Online (Sandbox Code Playgroud)

java runtime-error

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

为什么我的全球表被认为是零?

背景:

我正在努力教自己Lua,我很难理解为什么一个表在其中包含数据时被认为是nil.任何人都可以为我分解为什么我从下面的代码片段中收到此错误消息?这是我的第一个程序之一,我真的需要在继续我的真实项目之前先了解这几个概念.谢谢!

错误信息:

C:\Users\<user>\Desktop>lua luaCrap.lua
lua: luaCrap.lua:7: attempt to call global 'entry' (a nil value)
stack traceback:
        luaCrap.lua:7: in main chunk
        [C]: ?
Run Code Online (Sandbox Code Playgroud)

码:

--this creates the function to print
function fwrite (fmt, ...)
  return io.write(string.format(fmt, unpack(arg)))
end

--this is my table of strings to print
entry{
    title = "test",
    org = "org",
    url = "http://www.google.com/",
    contact = "someone",
    description = [[
                    test1
                    test2
                    test3]]
}

--this is to print the tables first value  
fwrite(entry[1])

--failed loop attempt to print …
Run Code Online (Sandbox Code Playgroud)

printing null lua runtime-error lua-table

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

在指针上调用delete时发生C++崩溃

我用结构和指针( - >)编写了一个小程序.所以我已经声明了一个指向同一结构中另一个对象的对象指针.但是当在应用程序上调用delete时会崩溃.

这是错误

Debug Assertion Failed
File:f:\dd\vctools\crt_bld\self_86x\crt\src\dbgdel.cpp
Line 52
Expression:_BLOCK_TYPE_IS_VALID(pHead -> nBlockUse)
Run Code Online (Sandbox Code Playgroud)

这里也是我的代码(ps当我从程序中删除删除时不会发生此错误)

#include <iostream>
#include <string>
#include <Windows.h>
#include <sstream>
using namespace std;

//declare structure to store info about Billy
struct Son{
    string name;
    string crush;
    int age;
    string hobbies[3];
}Person;

int main(){
    string sAge;
    int i;
    Son* info = new Son;
    info = &Person;
    //user interface
    //Person's name
    cout << "Person's name: ";
    getline(cin, info ->name); //inputs person's name
    //Person's age
    cout << "Person's age: ";
     //inputs …
Run Code Online (Sandbox Code Playgroud)

c++ pointers runtime-error

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

无法弄清楚二进制搜索算法出错的地方

我在C语言上尝试了这种(二分搜索)算法,其功能是在短时间内从一堆数字中找到一个数字.这是一种非常流行的技术.您也可以在Google上阅读相关内容.对我来说,它不适用于54和35,即最后两个数组.每当我想要搜索这两个数字时,它会显示"找不到项目".对于其余的数字,即前4个数组的数组,它工作正常.

#include <stdio.h>
#include <math.h>
int main(void)
{
    int item,beg=0,end=6,mid,a[6]={10,21,32,43,54,35};
    mid=(beg+end)/2;
    mid=round(mid);
    printf("Enter the number you want to search: ");
    scanf("%d", &item);
    printf("Item you entered is %d\n",item);
    while((a[mid]!=item) & (beg<=end))
    {
        if (item<a[mid])
            end=mid-1;
        else
            beg=mid+1;
        mid=(beg+end)/2;
        mid=round(mid);
    }

    if (item==a[mid])
        printf("Your number is at location %d in array and the number is %d",mid,a[mid]);
    else
        printf("Item not found");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c algorithm runtime-error binary-search

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