1.1. 실습 1 : 대문자로 바꾸는 함수 ¶
- 코드
 
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
void toUpper(char* str);
int main()
{
	char input[100];
	printf("\n 문자열을 입력하세요(영문자로만 공백없이) : ");
	gets(input);
	toUpper(input);
	printf("\n 변환된 문자열 : ");
	puts(input);
	return 0;
}
//알파벳 소문자를 대문자로 변환하는 함수
void toUpper(char* str){
}
1.2. 실습 2 : 내가 좋아하는 색깔은? ¶
#include "header.h"
#ifdef String_Quiz
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main()
{
	char input[7][10] = { "red", "blue", "orange", "green", "black", "white", "pink" };
        char* computerColor = input[random];    //computerColor : 컴퓨터가 좋아하는 색깔
	char* comp = "Computer", *user = "User";
	srand(time(NULL));
	int random = rand() % 7;     //컴퓨터가 좋아하는 색깔 생성하기
	printf("%10s : what is your favorite color? ", comp);
	//문자열을 선언해서, strcpy로 "My favorite color is "로 초기화합니다.
        //gets로 내가 좋아하는 색을 입력받고
        //strcat을 써서 "My favorite color is <색깔이름>"이라는 문자열을 만듭니다.
	printf("%10s : ", user);
	//완성된 문자열을 여기서 출력해주세요.
	if (/* 만약에 컴퓨터와 내가 좋아하는 색깔이 같다면(strcmp를 사용) */){
		printf("%10s : We like same color!\n", comp);
	}
	else{
		printf("%10s : I don't like that color. I like %s\n", comp, computerColor);
	}
	return 0;
}
3. 과제 제출 ¶
== 현지==
#include<stdlib.h>
#include<time.h>
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include<stdlib.h>
#include<time.h>
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main()
{
{
char input710 = { "red", "blue", "orange", "green", "black", "white", "pink" };
char* comp = "Computer", *user = "User";
srand(time(NULL));
int random = rand() % 7; //컴퓨터가 좋아하는 색깔 생성하기
char* computerColor = inputrandom;//computerColor : 컴퓨터가 좋아하는 색깔
printf("%10s : what is your favorite color? ", comp);
char str1100;
char str2100;
strcpy(str1, "My favorite color is");
gets(str2);
//문자열을 선언해서, strcpy로 "My favorite color is "로 초기화합니다.
//gets로 내가 좋아하는 색을 입력받고
//strcat을 써서 "My favorite color is <색깔이름>"이라는 문자열을 만듭니다.
printf("%10s : %s", user,strcat(str1,str2));
//완성된 문자열을 여기서 출력해주세요.
if (strcmp(computerColor,str2)==0) {
else {
return 0;
}srand(time(NULL));
int random = rand() % 7; //컴퓨터가 좋아하는 색깔 생성하기
char* computerColor = inputrandom;//computerColor : 컴퓨터가 좋아하는 색깔
printf("%10s : what is your favorite color? ", comp);
char str1100;
char str2100;
strcpy(str1, "My favorite color is");
gets(str2);
//문자열을 선언해서, strcpy로 "My favorite color is "로 초기화합니다.
//gets로 내가 좋아하는 색을 입력받고
//strcat을 써서 "My favorite color is <색깔이름>"이라는 문자열을 만듭니다.
printf("%10s : %s", user,strcat(str1,str2));
//완성된 문자열을 여기서 출력해주세요.
if (strcmp(computerColor,str2)==0) {
printf("%10s : We like same color!\n", comp);
}else {
printf("%10s : I don't like that color. I like %s\n", comp, computerColor);
}return 0;
3.1. 현지 ¶
#include<stdlib.h>
#include<time.h>
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main()
{
	char input[7][10] = { "red", "blue", "orange", "green", "black", "white", "pink" };
	    
	char* comp = "Computer", *user = "User";
	srand(time(NULL));
	int random = rand() % 7;     //컴퓨터가 좋아하는 색깔 생성하기
	char* computerColor = input[random];//computerColor : 컴퓨터가 좋아하는 색깔
	printf("%10s : what is your favorite color? ", comp);
	
	char str1[100];
	char str2[100];
	strcpy(str1, "My favorite color is");
	gets(str2);
	//문자열을 선언해서, strcpy로 "My favorite color is "로 초기화합니다.
	//gets로 내가 좋아하는 색을 입력받고
	//strcat을 써서 "My favorite color is <색깔이름>"이라는 문자열을 만듭니다.
	printf("%10s : %s", user,strcat(str1,str2));
	//완성된 문자열을 여기서 출력해주세요.
	if (strcmp(computerColor,str2)==0) {
		printf("%10s : We like same color!\n", comp);
	}
	else {
		printf("%10s : I don't like that color. I like %s\n", comp, computerColor);
	}
	return 0;
}
3.2. 유진 ¶
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main()
{
	char input[7][10] = { "red", "blue", "orange", "green", "black", "white", "pink" };
	
	char* comp = "Computer", *user = "User";
	srand(time(NULL));
	int random = rand() % 7;     //컴퓨터가 좋아하는 색깔 생성하기
	char* computerColor = input[random];    //computerColor : 컴퓨터가 좋아하는 색깔
	printf("%10s : what is your favorite color? \n", comp);
	//문자열을 선언해서, strcpy로 "My favorite color is "로 초기화합니다.
	char str[50];
	strcpy(str, "My favorite color is ");
	//gets로 내가 좋아하는 색을 입력받고
	char color[10];
	gets(color);
	//strcat을 써서 "My favorite color is <색깔이름>"이라는 문자열을 만듭니다.
	strcat(str, color);
	printf("%10s : ", user);
	//완성된 문자열을 여기서 출력해주세요.
	printf("%s\n", str);
	if (/* 만약에 컴퓨터와 내가 좋아하는 색깔이 같다면(strcmp를 사용) */strcmp(computerColor,color)==0)
	{
		printf("%10s : We like same color!\n", comp);
	}
	else{
		printf("%10s : I don't like that color. I like %s\n", comp, computerColor);
	}
	return 0;
}
4.1. 물주는사람 ¶
부족하고 서툴지만 예쁜 새싹들이 잘 들어주고 따라와주어 고맙습니다.
실습이 조금 난해했던 것 같네요. 다음엔 더 재미있고 깔끔한 실습예제를 들고와야겠습니다.
실습이 조금 난해했던 것 같네요. 다음엔 더 재미있고 깔끔한 실습예제를 들고와야겠습니다.










