Skip to content

Instantly share code, notes, and snippets.

View k0u5uk3's full-sized avatar

Kousuke Shimofuji k0u5uk3

View GitHub Profile
@k0u5uk3
k0u5uk3 / gist:be7564956b6191bdaae4
Last active December 21, 2019 16:58
firstprog.c
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 10; i++) // 10回繰り返す
{
printf("Hello, world!\n"); // 文字列を出力する
}
return 0; // プログラムが問題なく終了したことをOSに知らせる
#include <stdio.h>
int main()
{
char str_a[20];
str_a[0] = 'H';
str_a[1] = 'e';
str_a[2] = 'l';
str_a[3] = 'l';
str_a[4] = 'o';
str_a[5] = ',';
#include <stdio.h>
#include <string.h>
int main() {
char str_a[20];
strcpy(str_a, "Hello, world!\n");
printf(str_a);
}
#include <stdio.h>
int main() {
printf("The 'int' data type is\t\t %d bytes\n", sizeof(int));
printf("The 'unsigned int' data type is\t %d bytes\n", sizeof(unsigned int));
printf("The 'short int' data type is\t %d bytes\n", sizeof(short int));
printf("The 'long int' data type is\t %d bytes\n", sizeof(long int));
printf("The 'long long int' data type is %d bytes\n", sizeof(long long int));
printf("The 'float' data type is\t %d bytes\n", sizeof(float));
printf("The 'char' data type is\t\t %d bytes\n", sizeof(char));
#include <stdio.h>
#include <string.h>
int main() {
char str_a[20]; // 20個の要素を持つ文字の配列
char *pointer; // 文字の配列を指すポインタ
char *pointer2; // 同じく、文字の配列を指すポインタ
strcpy(str_a, "Hello, world!\n");
pointer = str_a; // 1つ目のポインタが配列の戦闘を指すように設定する
#include <stdio.h>
int main() {
int int_var = 5;
int *int_ptr;
int_ptr = &int_var; // int_varのアドレスをint_ptrに設定する
}
@k0u5uk3
k0u5uk3 / gist:ef5c5280666b0a4f2ba0
Last active August 29, 2015 14:22
address0f2.c
#include <stdio.h>
int main(){
int int_var = 5;
int *int_ptr;
int_ptr = &int_var; // int_varのアドレスをint_ptrに設定する
printf("int_ptr = 0x%08x\n", int_ptr);
printf("&int_ptr = 0x%08x\n", &int_ptr);
#include <stdio.h>
#include <string.h>
int main() {
char string[10];
int A = -73;
unsigned int B = 31337;
strcpy(string, "sample");
#include <stdio.h>
#include <string.h>
int main() {
char message[20];
int count, i;
strcpy(message, "Hello, world!");
printf("何度繰り返しますか?");
#include <stdio.h>
int main(){
int a, b;
float c, d;
a = 13;
b = 5;
c = a / b; // 整数による除算
d = (float) a / (float) b; // 整数を浮動小数点にキャストした後の除算