$ gcc -o app main.c
$ ./app
16975631 16975631 1807 15
15
7
3
1
15
7
3
1
15
7
3
1
Last active
September 3, 2023 09:18
-
-
Save devlights/7b50367bf3d5e47a3f66109b72741e23 to your computer and use it in GitHub Desktop.
C言語おさらい(自分用)
This file contains 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> | |
void fn(char *a, int len) { | |
for (int i = 0; i < len; i++) { | |
printf("%d\n", a[i]); | |
} | |
} | |
int main(void) { | |
// 1 3 7 15 | |
int i = 0b00000001000000110000011100001111; | |
int *p1 = &i; | |
short *p2 = (short *)p1; | |
char *p3 = (char *)p1; | |
printf("%d\t%d\t%d\t%d\n", i, *p1, *p2, *p3); | |
for (int y = 0; y < 4; y++) { | |
printf("%d\n", *(p3+y)); | |
} | |
for (int y = 0; y < 4; y++) { | |
printf("%d\n", p3[y]); | |
} | |
fn(p3, 4); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment