#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
char title[128] = {0, };
char author[128] = { 0, };
int price= 0;
strcpy(title, "야옹이 수영교실");
strcpy(author, "신현경");
price = 14220;
printf("%s\\r\\n", title);
printf("%s\\r\\n", author);
printf("%d\\r\\n", price);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
char title1[128] = {0, };
char author1[128] = { 0, };
int price1= 0;
char title2[128] = { 0, };
char author2[128] = { 0, };
int price2 = 0;
char title3[128] = { 0, };
char author3[128] = { 0, };
int price3 = 0;
strcpy(title1, "야옹이 수영교실");
strcpy(author1, "신현경");
price1 = 14220;
strcpy(title2, "천개산 패밀리");
strcpy(author2, "박현숙");
price2 = 12600;
strcpy(title3, "세상은 이야기로 만들어졌다");
strcpy(author3, "자미라 엘 우아실");
price3 = 24300;
int tmp_cnt = 0;
printf("[%d] ", ++tmp_cnt);
printf("%s /", title1);
printf("%s /", author1);
printf("%d", price1);
printf("\\r\\n");
printf("[%d] ", ++tmp_cnt);
printf("%s /", title2);
printf("%s /", author2);
printf("%d", price2);
printf("\\r\\n");
printf("[%d] ", ++tmp_cnt);
printf("%s /", title3);
printf("%s /", author3);
printf("%d", price3);
printf("\\r\\n");
return 0;
}
책 제목이 바뀌는건 아니니까 char*로 만들면.. 좀 낫나?
위에보다 조금 낫긴 하다. strcpy() 이거 안써도 되니까.
조금 낫다는 거지 좋다고는 안했다.
이게 문제가 되는 이유는
title1, author1, price1과 아무런 연관이 없다는 점이다.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
char* title1 = "야옹이 수영교실";
char* title2 = "천개산 패밀리";
char* title3 = "세상은 이야기로 만들어졌다";
char* author1 = "신현경";
char* author2 = "박현숙";
char* author3 = "자미라 엘 우아실";
int price1 = 14220;
int price2 = 12600;
int price3 = 24300;
int tmp_cnt = 0;
printf("[%d] ", ++tmp_cnt);
printf("%s /", title1);
printf("%s /", author1);
printf("%d", price1);
printf("\\r\\n");
printf("[%d] ", ++tmp_cnt);
printf("%s /", title2);
printf("%s /", author2);
printf("%d", price2);
printf("\\r\\n");
printf("[%d] ", ++tmp_cnt);
printf("%s /", title3);
printf("%s /", author3);
printf("%d", price3);
printf("\\r\\n");
return 0;
}