这个C++小程序为什么总是崩溃

100关注2767浏览

//不停输入数字并储存知道输入0
//好吧我也知道多半和越界有关但是我是在看不出来= =

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int in;
int times=0;
int* p

共4条回答
  • Fan番
    7年前

    加个return 0;试试

    0 15

  • Jasper
    7年前

    #include <cstdlib>
    #include <iostream>
    using namespace std;
    int main(int argc, char *argv[])
    {
    int in;
    int times=0;
    int* tmp=new int,*pin;
    while(cin>>in)
    {

    if(

    0 13

  • 左鹏
    7年前

    你试试 if(cin!=0) 改成 if(in!=0);

    0 12

  • 苯巴比妥
    7年前

    if(cin!=0)
    {
    tmp=pin;
    times++;
    pin=new int[times];

    for(int i=0;i<times;i++) //pin恢复备份
    {

    0 5

发送