C ++代码中的问题....没有编译和未处理的异常发生.... [英] Problem in C++ code....Does not compile and unhandled exception occurs....

查看:52
本文介绍了C ++代码中的问题....没有编译和未处理的异常发生....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void bsort (int *s, int index)
{
    int temp;
 for (int i=0; i=index-1; i++)
 {
     for (int j=1; j=index; j++)
     {
         if (*(s+i)=*(s+j))
         {
             temp=*(s+i);
             *(s+i)=*(s+j);
             *(s+j)=temp;
         }
     }
 }

}

int main ()
{
    void bsort (int *, int n);

    int arr[5]= {5,4,3,2,1};
    for (int i=0; i<5; i++)
    {
        cout<<arr[i]<<endl;
    }

    bsort (arr, 5);

    for (int i=0; i<5; i++)
    {
        cout<<arr[i]<<endl;
    }

    getche();
    return(0);

}

推荐答案

嗯。

你看过你的代码了吗? :笑:

Um.
Did you look at your code? :laugh:
for (int i=0; i=index-1; i++)

已提供 index 不等于1,然后永远不会结束...

您的意思是:

Provided index is not equal to 1, then will never end...
Did you mean:

for (int i=0; i==index-1; i++)

相反?



(别担心,这是我们所犯的错误!)

Instead?

(Don't worry, it's a mistake we all make!)


对不起,没有。您在问题标题中报告的内容不正确。 不编译和未处理的异常发生是相互排除的条件。如果您发现了一些异常,那肯定意味着代码编译。如果代码没有编译,你将无法观察到异常。



如果发现异常,请使用调试器。如果您还有其他问题,请提供全面的例外信息;重要的是,在代码中显示抛出的行。



-SA
Sorry, no. What you report in your question title is not true. "Does not compile and unhandled exception occurs" are mutually excluding conditions. If you observed some exception, it certainly would mean the the code compiles. And if code did not compile, you would not be able to observe exception.

If you observe an exception, use the debugger. If you have further questions, provide comprehensive exception information; importantly, show in what line it was thrown, in code.

—SA


这篇关于C ++代码中的问题....没有编译和未处理的异常发生....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆