-
-
Save iwadon/5243888 to your computer and use it in GitHub Desktop.
Visual Studio 2012 for Windows Desktopで配列の添字を省略できるかどうかを確認してみた。
→[]でも[0]でも結果は変わらず。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| struct A | |
| { | |
| int i[]; | |
| }; | |
| int main(int argc, char *argv[]) | |
| { | |
| struct A *a = malloc(sizeof (struct A) + sizeof (int) * 3); | |
| a->i[0] = 0; | |
| a->i[1] = 1; | |
| a->i[2] = 2; | |
| printf("%d %d %d\n", a->i[0], a->i[1], a->i[2]); | |
| free(a); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >cl a.c | |
| Microsoft(R) C/C++ Optimizing Compiler Version 17.00.60204.1 for x64 | |
| Copyright (C) Microsoft Corporation. All rights reserved. | |
| a.c | |
| Microsoft (R) Incremental Linker Version 11.00.60204.1 | |
| Copyright (C) Microsoft Corporation. All rights reserved. | |
| /out:a.exe | |
| a.obj | |
| >a.exe | |
| 0 1 2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment