0512๐ŸŽจ

์ด์›๋นˆยท2025๋…„ 5์›” 12์ผ
0

๊ตฌ์กฐ์ฒด: ์„œ๋กœ ๋‹ค๋ฅธ ํƒ€์ž…์˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ•˜๋‚˜์˜ ๋‹จ์œ„๋กœ ๋ฌถ์„ ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ

strcpy ๋ฌธ์ž์—ด ๋ null(= '\0') ๊นŒ์ง€ ๋ณต์‚ฌ

#include <stdio.h>
#include <string.h>
#include <stdlib.>

struct strudent{

int 10;
char name[20];
int age;
};

int main() {
struct strict s1;
s1.id = 101;
s1.age = 20;
strcpy = string copy









https://blockdmask.tistory.com/348

// ๊ตฌ์กฐ์ฒด : ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ๋ฅผ ํ•˜๋‚˜๋กœ ๋ฌถ์–ด์„œ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐ ๊พธ๋Ÿฌ๋ฏธ
struct People{
char name;
int age;
};
struct Address{
char
city; // ๋„์‹œ
int num; // ์šฐํŽธ๋ฒˆํ˜ธ
};
struct Student{
char name;
int age;
struct Address addr;
};
int main() {
struct People p1;
// . ์—ฐ์‚ฐ์ž๋ฅผ ์ด์šฉํ•ด ๋ฉค๋ฒ„๋ณ€์ˆ˜์— ์ ‘๊ทผ
char a = 10;
char
p = &a;
// ๊ตฌ์กฐ์ฒด + ํฌ์ธํ„ฐ
struct Student s;
s.name = "ํ™๊ธธ๋™";
s.age = 20;
s.addr.city = "์„œ์šธ";
s.addr.num = 1234;
printf("%s\n",s.addr.city);
struct Student ps = &s;
printf("%d\n", (
ps).age);
printf("%d\n", ps->age);
// -> ์—ฐ์‚ฐ์ž ์™ผ์ชฝ์€ ๋ฌด์กฐ๊ฑด ๊ตฌ์กฐ์ฒด ์ฃผ์†Œ
int arr[3]= {1,2,3};
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
printf("%d\n", *p);
return 0;
}

0๊ฐœ์˜ ๋Œ“๊ธ€