Note: C++ does not support default-int

不羁的心 提交于 2020-01-24 13:09:10

问题


I'm getting this message in Visual Studio:

Note: C++ does not support default-int

What's wrong with my C code?

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void remplire (int t[], int n);
void afficher (int t[], int n);

void main ()
{
    const long_tab = 2000;
    int t[long_tab];
    srand (time(NULL));
    remplire (t, long_tab);
    afficher (t, long_tab);
}

void remplire (int t[], int n)
{
    int i;
    for (i = 0; i <= n; i++)
    {
        t[i] = rand (); 
    }
}

void afficher (int t[], int n)
{
    int i;
    for (i = 0; i <= n; i++)
    {
        printf ("%d \t", t[i]);
        if (i % 10 == 0)
            printf ("\n");
    }
}

回答1:


C++ shows this error when you omit the identifier type.

const int variable1; //OK
const variable2; //Not OK

This is MSDN description of the error:

http://msdn.microsoft.com/en-us/library/ms173696%28VS.80%29.aspx

Also, if you highlight the error in the output tab and press F1 - Visual Studio Help will show you a page explaining the error in more detail, similar to the link above.




回答2:


const long_tab = 2000 should be const int long_tab = 2000. You may have other problems too, but I can't easily read your code because it got badly reformatted by SO.



来源:https://stackoverflow.com/questions/1962449/note-c-does-not-support-default-int

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!