Skip to main content
Commonmark migration
Source Link

#C

C

sizeof(char[n][n])

It works up to INT_MAX in constant time and without memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609

#C

sizeof(char[n][n])

It works up to INT_MAX in constant time and without memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609

C

sizeof(char[n][n])

It works up to INT_MAX in constant time and without memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609
added 5 characters in body
Source Link
Florian F
  • 591
  • 4
  • 9

#C

sizeof(char[n][n])

It works up to INT_MAX in constant time and nowithout memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609

#C

sizeof(char[n][n])

It works up to INT_MAX in constant time and no memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609

#C

sizeof(char[n][n])

It works up to INT_MAX in constant time and without memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609
added 270 characters in body
Source Link
Florian F
  • 591
  • 4
  • 9

#C

sizeof(char[n][n])

asIt works up to INT_MAX in constant time and no memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

It works up to INT_MAX in constant time and no memory allocation.displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609

#C

sizeof(char[n][n])

as in

#include <stdio.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
}

It works up to INT_MAX in constant time and no memory allocation.

#C

sizeof(char[n][n])

It works up to INT_MAX in constant time and no memory allocation.

Example:

#include <stdio.h>
#include <limits.h>
int main(){
    for( int n=0 ; n<10 ; n++ ){
        printf("%d: %ld\n", n, sizeof(char[n][n]));
    }
    int n = INT_MAX;
    printf("%d: %ld\n", n, sizeof(char[n][n]));
}

displays

0: 0
1: 1
2: 4
3: 9
4: 16
5: 25
6: 36
7: 49
8: 64
9: 81
2147483647: 4611686014132420609
added 42 characters in body
Source Link
Florian F
  • 591
  • 4
  • 9
Loading
added 22 characters in body
Source Link
Florian F
  • 591
  • 4
  • 9
Loading
Source Link
Florian F
  • 591
  • 4
  • 9
Loading