Loop restriction in C / C ++

Is there a limit on how many loop cycles can be executed in C?


void main()
{
    int T,N,x,X,i;
    x=0;
    scanf("%d",&T);
    while(T>0)
    {
        T--;
        scanf("%d",&N);
        X=0;
        while(N>0)
        {
            N--;
            scanf("%d",&x);
            if(x>X){X=x;}
        }
        printf("Case: %d",x);
    }
}

T has a range of 0-250, and N has a range of 0-1000. x has a range of 0-10,000. Whenever N exceeds something above 800, my console stops accepting input. Could this be due to an input buffer limitation?

+3
source share
4 answers

There are no restrictions on how many times the loop can loop. There are limits to the maximum and minimum values int, and they can be played in your loop. In this case, 800 should be beautiful, so something else happens here.

: ... , , , reset X , , > 0 0.

+4

? - . .

+2

, wiki , :

scanf. , , API - " ", eax scanf x86. . () (0) EOF. 1976 , scanf .

, , , " " "". , , filename.dat. , :

executable-name < filename.dat

- , C. , " " " stdin" - (0), stdin. , , scanf , ( ).

" ", , stdin. , , popen, open. :

cat filename.dat | executable-name Unix-,

type filename.dat | executable-name, IBM & reg; PC-DOS & ; .

+1

10 000 () , .

, , .;)

+1

Source: https://habr.com/ru/post/1760601/


All Articles