ex20250519 - rlawjdaks/ex20250310_first GitHub Wiki

#include <stdio.h>
int main() {
	//char s[4] = "ABC";
	//char s[4] = { 'A', 'B', 'C', '\0' };
	char s[4] = { 'A', 'B', 'C' };

	printf("string: %s\n", s);
	printf("string: %s\n", &s[0]);
	
	printf("%c\n", s[0]);
	printf("%c\n", s[1]);
	printf("%c\n", s[2]);
	// 'A' 'B' 'c'
}

#include <stdio.h>
int main() {
	//char s[4] = "ABC";
	//char s[4] = { 'A', 'B', 'C', '\0' };
	//char s[] = { 'A', 'B', 'C' };  //3 생략 (Null이 없어서 오류)
	char s[] = "ABC"; //4 생략 

	printf("string: %s\n", s);
	printf("string: %s\n", &s[0]);

	printf("%c\n", s[0]);
	printf("%c\n", s[1]);
	printf("%c\n", s[2]);
	// 'A' 'B' 'c'
}

#include <stdio.h>
int g = 200;
int* pg = &g;

void PrintGlobalData() {
	printf("gd : %d %d\n", g, *pg);
	//printf("gd : %d %d\n", n, *p);

}
int main() {
	
	//메모리/ 변수, 상수 
	int n = 10;
	int* p = &n;

	printf("%d %d\n", n, *p);
}

#include <stdio.h>

void PrintInteger(int data) {
	printf("data : %d\n", data);
}
int main() {
	PrintInteger(10);
	int n = 20;
	PrintInteger(n);
}

#include <stdio.h> // printf()
#include <stdlib.h> //malloc(), free()
int main() {
	int* p = malloc(4);

	*p = 100;
	printf("data : %d\n", *p);

	free(p);
}

#include <stdio.h> // printf()
#include <stdlib.h> //malloc(), free()
int main() {
	double* p = malloc(8);

	*p = 100.67;
	printf("data : %g\n", *p);

	free(p);
}

#include <stdio.h> // printf()
#include <stdlib.h> //malloc(), free()
int main() {
	double* p = malloc(sizeof(double));

	*p = 100.67;
	printf("data : %g\n", *p);

	free(p);
}

#include <stdio.h> // printf()
#include <stdlib.h> //malloc(), free()
int main() {
	int* p = malloc(sizeof(int));

	*p = 10;
	printf("data : %d\n", *p);

	free(p);
}

#include <stdio.h> // printf()
#include <stdlib.h> //malloc(), free()
int main() {
	int* p = malloc(sizeof(int)*4);

	p[0] = 10;
	p[1] = 20;
	p[2] = 30;
	p[3] = 40;
	printf("data : %d\n", p[0]);
	printf("data : %d\n", p[1]);
	printf("data : %d\n", p[2]);
	printf("data : %d\n", p[3]);

	free(p);
}
⚠️ **GitHub.com Fallback** ⚠️