modoocode.com Ads.txt file

<!DOCTYPE html>
<html lang="ko-kr">
<head>
<!-- Google tag (gtag.js) -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-51YBZ401K4"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());

gtag("config", "G-51YBZ401K4");
</script>
<link
href="https://fonts.googleapis.com/css?family=Noto+Sans+KR|Source+Code+Pro&display=swap"
rel="stylesheet"
/>
<link href="http://gmpg.org/xfn/11" rel="profile" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="canonical" href="https://modoocode.com" />

<!-- Enable responsiveness on mobile devices-->
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1"
/>

<link rel="stylesheet" type="text/css" href="/css/index.css" />

<!-- Icons -->
<link rel="icon" href="/img/ChewingCppFav.png" type="image/png" />
<title>모두의 코드</title>
</head>
<body>
<section class="header">
<div class="header-img">
<img src="/img/tux.jpeg" alt="모두의 코드" />
</div>
<div class="header-title">
<a href="/">모두의 코드</a>
</div>
</section>
<main>
<div class="content">
<div class="row-content">
<div class="item">
<div class="item-img">
<a href="/notice/15">
<picture>
<source type="image/webp" srcset="/img/ChewingClogo.webp" />
<img
src="/img/ChewingClogo.png"
alt="씹어먹는 C 언어 강좌 보러가기"
/>
</picture>
</a>
</div>
<div class="item-text">
<div class="item-text-header">
<a href="/notice/15">씹어먹는 C 언어 강좌</a>
</div>
<div class="item-text-content">
<p>
총 42 개의 강의로 준비된
<span class="text-bold">씹어먹는 C 언어 강좌</span>를 통해 C
언어의 처음부터 끝까지 배우실 수 있습니다! 특히 악명 높은 C
언어의 포인터나, 어려운 개념들을 충실히 짚고 넘어갑니다.
</p>
<p>
이 강좌는 2010년에 완결되었지만, 지속적으로 개선 및 보완하고
있습니다.
</p>
</div>
</div>
</div>
<div class="item">
<div class="item-img">
<a href="/135">
<picture>
<source type="image/webp" srcset="/img/ChewingCpplogo.webp" />
<img
src="/img/ChewingCpplogo.png"
alt="씹어먹는 C ++ 강좌 보러가기"
/>
</picture>
</a>
</div>
<div class="item-text">
<div class="item-text-header">
<a href="/135">씹어먹는 C++ 강좌</a>
</div>
<div class="item-text-content">
<p>
C 언어 문법을 아시는 분들이라면,
<span class="text-bold">씹어먹는 C++ 강좌</span>를 통해 C++
기초 부터 최근의 C++ 17 까지 모든 내용을 배우실 수 있습니다. C
언어와 C++ 의 기본적인 문법이 비슷하기 때문에, C 언어를 어느
정도 아는 독자를 가정하여 쓰여져 있습니다.
</p>
<p>
이 강좌는 2020년에 완결되었고 총 50 개의 강좌가 준비되어
있습니다.
</p>
</div>
</div>
</div>
</div>
<div class="row-content">
<div class="item">
<div class="item-img">
<a href="/245">
<picture>
<source type="image/webp" srcset="/img/ModooAlgo.webp" />
<img
src="/img/ModooAlgo.png"
alt="씹어먹는 C ++ 강좌 보러가기"
/>
</picture>
</a>
</div>
</div>
<div class="item" style="display: flex">
<div class="enter-community">
<a href="https://forum.modoocode.com"
>모두의 코드 대화방 들어가기</a
>
</div>
</div>
</div>
<div class="row-content">
<div class="item">
<div class="search-bar-text">사이트 내에서 검색 하기</div>
<div class="cse">
<script>
(function () {
var cx = "003869586044905610715:visr8hwbmrq";
var gcse = document.createElement("script");
gcse.type = "text/javascript";
gcse.async = true;
gcse.src = "https://cse.google.com/cse.js?cx=" + cx;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
</div>
</div>
<div class="row-content">
<div class="item">
<div class="new-article">
<div class="item-text-header">
최근 글<span class="new-article-deco">Recent Articles</span>
</div>

<div class="new-article-entry">
<a href="338"
>Rust 의 레퍼런스들에 관한 규칙들</a
>

<span class="new-article-new">New</span>

</div>

<div class="new-article-entry">
<a href="336"
>사이트 새 단장</a
>

<span class="new-article-new">New</span>

</div>

<div class="new-article-entry">
<a href="335"
>씹어먹는 C++ - &lt;22. 구글에서는 C++ 을 어떻게 쓰는가?&gt;</a
>

</div>

<div class="new-article-entry">
<a href="334"
>Rust 의 다형성 - static 과 dynamic dispatch (C++ 을 곁들인..)</a
>

</div>

<div class="new-article-entry">
<a href="333"
>Rust 의 static 키워드</a
>

</div>

</div>
</div>
<div class="item">
<div class="visitor-box">
<canvas id="visitors"></canvas>
</div>
</div>
</div>
<div class="row">
<div class="ref-box">
<div class="ref-header">C 언어 레퍼런스</div>
<div class="ref-content">
<div class="ref-col">
<div class="ref-col-header">
표준 입출력 라이브러리 <a href="/34">stdio.h</a>
</div>
<div class="ref-col-content">
<ul>
<li><a href="/35">printf</a></li>
<li><a href="/36">scanf</a></li>
<li><a href="/66">sprintf</a></li>
<li><a href="/58">fopen</a></li>
</ul>
</div>
</div>
<div class="ref-col">
<div class="ref-col-header">
문자열 관련 라이브러리 <a href="/76">string.h</a>
</div>
<div class="ref-col-content">
<ul>
<li><a href="/106">strlen</a></li>
<li><a href="/36">strncmp</a></li>
<li><a href="/101">strstr</a></li>
<li><a href="/77">memcpy</a></li>
</ul>
</div>
</div>
<div class="ref-col">
<div class="ref-col-header">
시간 관련 라이브러리 <a href="/108">time.h</a>
</div>
<div class="ref-col-content">
<ul>
<li><a href="/114">time</a></li>
<li><a href="/110">clock</a></li>
<li><a href="/111">difftime</a></li>
<li><a href="/122">strftime</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="ref-box">
<div class="ref-header">C ++ 레퍼런스</div>
<div class="ref-content">
<div class="ref-col">
<div class="ref-col-header">
표준 입출력 라이브러리 <a href="/143">iostream</a>
</div>
<div class="ref-col-content">
<ul>
<li><a href="/151">ifstream</a></li>
<li><a href="/157">ios_base::precision</a></li>
<li><a href="/149">istream::getline</a></li>
<li><a href="/191">istream::get</a></li>
</ul>
</div>
</div>
<div class="ref-col">
<div class="ref-col-header">
문자열 라이브러리 <a href="/233">string</a>
</div>
<div class="ref-col-content">
<ul>
<li><a href="/234">string</a></li>
<li><a href="/239">string_view</a></li>
<li><a href="/235">substr</a></li>
<li><a href="/241">find</a></li>
</ul>
</div>
</div>
<div class="ref-col">
<div class="ref-col-header">
알고리즘 라이브러리 <a href="/256">algorithm</a>
</div>
<div class="ref-col-content">
<ul>
<li><a href="/261">find</a></li>
<li><a href="/260">for_each</a></li>
<li><a href="/262">count</a></li>
<li><a href="/265">find_end</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="row-content">
<div class="item">
<div class="item-text">
<div class="item-text-header comment">최근 댓글</div>
<div class="item-text-content">

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;89"
>
문제1
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;


int get_length(char *cp);
void set_digit(int *p, int len);

int main(int args, char **argv)
{
&#x2F;&#x2F;argv[0] 은 실행경로
char oper = argv[2][0];
char ch1[10];
char ch2[10];

int a = 0;
int b = 0;

strcpy(ch1, argv[1]);
strcpy(ch2, argv[3]);

int digit[10];

int len1 = get_length(ch1);
int len2 = get_length(ch2);

int max_len = (len1 &gt; len2) ? len1 : len2;

set_digit(digit, max_len);

int index = len1 - 1;

for(int i = 0; i &lt; len1; i++)
{
a += (ch1[i] - &#x27;0&#x27;) * digit[index];
index--;
}

index = len2 - 1;

for(int i = 0; i &lt; len2; i++)
{
b += (ch2[i] - &#x27;0&#x27;) * digit[index];
index--;
}

if(oper == &#x27;+&#x27;)
{
printf(&quot;%s + %s = %d\n&quot;, ch1, ch2, a + b);
}
else if(oper == &#x27;-&#x27;)
{

}

return 0;
}

int get_length(char *cp)
{
int len = 0;

while(*cp != &#x27;\0&#x27;)
{
len++;
cp++;
}

return len;
}

void set_digit(int *p, int len)
{
int num = 1;

for(int i = 0; i &lt; len; i++)
{
p[i] = num;
num *= 10;
}
}
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.19
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;88"
>
문제1
구조체가 선언되어 있는 헤더파일을 a.h 로 지정하고 중복으로 #include 한다면 구조체가 이미 선언되어 있는데 동일한 이름의 구조체가 또 선언되어 문제가 발생합니다. 아래와 같이 해결할 수 있습니다.
#ifndef A_HEADER

#define A_HEADER
#include &quot;a.h&quot;

#endif
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.18
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;87"
>
문제1
main.c
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &quot;str.h&quot;
#include &quot;library.h&quot;

int main(int argc, char *argv[]) {

struct Book book[100];

int order = 0;
int index = 0;

printf(&quot;도서관리 프로그램에 오신것을 환영합니다!\n&quot;);

while(1)
{
printf(&quot;1. 추가 &#x2F; 2. 검색 &#x2F; 3. 대출,반납 &#x2F; 4.종료\n&quot;);
scanf(&quot;%d&quot;, &amp;order);

if(order == 1)
{
add_book(book, &amp;index);
}
else if(order == 2)
{
search_book(book, index);
}
else if(order == 3)
{
borrow_book(book);
}
else if(order == 4)
{
break;
}
else if(order == 5)
{
for(int i = 0; i &lt; index; i++)
{
printf(&quot;%s\n&quot;, book[i].title);
printf(&quot;%s\n&quot;, book[i].author);
printf(&quot;%s\n&quot;, book[i].publ);
printf(&quot;%d\n&quot;, book[i].borrowed);
}
}
else
{
printf(&quot;알 수 없는 명령어\n&quot;);
}
}

return 0;
}

str.c
#include &quot;str.h&quot;

&#x2F;&#x2F;문자 길이 리턴
int get_len(char *pa)
{
int len = 0;

while(*pa != &#x27;\0&#x27;)
{
len++;
pa++;
}

return len;
}

&#x2F;&#x2F;문자열이 일치하는지 확인
int compare_string(char *cp1, char *cp2, int len1, int len2)
{
if(len1 == len2)
{
for(int i = 0; i &lt; len1; i++)
{
if(cp1[i] != cp2[i])
{
return -1;
}
}

return 0;
}

return -1;
}

&#x2F;&#x2F;입력한 문자열이 존재하는지 확인
int compare_string2(char *cp1, char *cp2, int len1, int len2)
{
for(int i = 0; i &lt; len1; i++)
{
int j = 0;

if(cp1[i] == cp2[j])
{
int k = i;
int cnt = 0;

while(1)
{
if(k &gt;= len1 || j &gt;= len2) break;

if(cp1[k] == cp2[j])
{
cnt++;
}

k++;
j++;
}

if(cnt == len2)
{
return i;
}
}
}

return -1;
}

str.h
int get_len(char *pa);
int compare_string(char *cp1, char *cp2, int len1, int len2);
int compare_string2(char *cp1, char *cp2, int len1, int len2);

library.c
#include &lt;stdio.h&gt;
#include &quot;library.h&quot;
#include &quot;str.h&quot;

&#x2F;&#x2F;책 추가
void add_book(struct Book *book, int *index)
{
printf(&quot;제목 : &quot;);
scanf(&quot;%s&quot;, (book + *index)-&gt;title);

printf(&quot;저자 : &quot;);
scanf(&quot;%s&quot;, (book + *index)-&gt;author);

printf(&quot;출판사 : &quot;);
scanf(&quot;%s&quot;, (book + *index)-&gt;publ);

(book + *index)-&gt;borrowed = 0;

printf(&quot;------------------추가완료------------------\n&quot;);
printf(&quot;번호 : %d\n&quot;, *index);
printf(&quot;제목 : %s\n&quot;, (book + *index)-&gt;title);
printf(&quot;저자 : %s\n&quot;, (book + *index)-&gt;author);
printf(&quot;출판사 : %s\n&quot;, (book + *index)-&gt;publ);
if((book + *index)-&gt;borrowed == 0)
{
printf(&quot;대출여부 : 대출가능\n&quot;);
}
else
{
printf(&quot;대출여부 : 대출됨\n&quot;);
}
printf(&quot;--------------------------------------------\n&quot;);
printf(&quot;\n&quot;);

*index = *index + 1;
}

&#x2F;&#x2F;책 찾기
void search_book(struct Book *book, int index)
{
int order = 0;
int len1 = 0;
int len2 = 0;

char c[30];

printf(&quot;1. 제목으로 찾기 &#x2F; 2. 저자로 찾기 &#x2F; 3. 출판사로 찾기 &#x2F; 4. 뒤로가기\n&quot;);
scanf(&quot;%d&quot;, &amp;order);

if(order == 1)
{
int cnt = 0;

printf(&quot;제목 : &quot;);
scanf(&quot;%s&quot;, c);

len2 = get_len(c);

for(int i = 0; i &lt; index; i++)
{
len1 = get_len((*(book + i)).title);
int result = compare_string2((*(book + i)).title, c, len1, len2);

if(result != -1)
{
show_book_info((*(book + i)), i);
cnt++;
}
}

if(cnt == 0)
{
printf(&quot;일치하는 정보가 없습니다.\n\n&quot;);
}
}
else if(order == 2)
{
int cnt = 0;

printf(&quot;저자 : &quot;);
scanf(&quot;%s&quot;, c);

len2 = get_len(c);

for(int i = 0; i &lt; index; i++)
{
len1 = get_len((*(book + i)).author);
int result = compare_string2((*(book + i)).author, c, len1, len2);

if(result == 0)
{
show_book_info((*(book + i)), i);
cnt++;
}
}

if(cnt == 0)
{
printf(&quot;일치하는 정보가 없습니다.\n\n&quot;);
}
}
else if(order == 3)
{
int cnt = 0;

printf(&quot;출판사 : &quot;);
scanf(&quot;%s&quot;, c);

len2 = get_len(c);

for(int i = 0; i &lt; index; i++)
{
len1 = get_len((*(book + i)).publ);
int result = compare_string2((*(book + i)).publ, c, len1, len2);

if(result == 0)
{
show_book_info((*(book + i)), i);
cnt++;
}
}

if(cnt == 0)
{
printf(&quot;일치하는 정보가 없습니다.\n\n&quot;);
}
}
}

&#x2F;&#x2F;책 대출, 반납
void borrow_book(struct Book *book)
{
int order = -1;

printf(&quot;1. 대출 &#x2F; 2. 반납 &#x2F; 3. 뒤로가기\n&quot;);
scanf(&quot;%d&quot;, &amp;order);

if(order == 1)
{
int num = -1;
printf(&quot;대출할 책 번호 : &quot;);
scanf(&quot;%d&quot;, &amp;num);

if((*(book + num)).borrowed == 1)
{
printf(&quot;이미 대출중 입니다.\n&quot;);
return;
}

(*(book + num)).borrowed = 1;

printf(&quot;------------------대출완료------------------\n&quot;);
show_book_info((*(book + num)), num);
}
else if(order == 2)
{
int num = -1;
printf(&quot;반납할 책 번호 : &quot;);
scanf(&quot;%d&quot;, &amp;num);

if((*(book + num)).borrowed == 0)
{
printf(&quot;이미 반납 됐습니다.\n&quot;);
return;
}

(*(book + num)).borrowed = 0;

printf(&quot;------------------반납완료------------------\n&quot;);
show_book_info((*(book + num)), num);
}
}

void show_book_info(struct Book book, int index)
{
printf(&quot;--------------------------------------------\n&quot;);
printf(&quot;번호 : %d\n&quot;, index);
printf(&quot;제목 : %s\n&quot;, book.title);
printf(&quot;저자 : %s\n&quot;, book.author);
printf(&quot;출판사 : %s\n&quot;, book.publ);
if(book.borrowed == 0)
{
printf(&quot;대출여부 : 대출가능\n&quot;);
}
else
{
printf(&quot;대출여부 : 대출됨\n&quot;);
}
printf(&quot;--------------------------------------------\n&quot;);
printf(&quot;\n&quot;);
}

library.h
struct Book{
char title[30];
char author[20];
char publ[20];
int borrowed;
};

void add_book(struct Book *book, int *index);
void search_book(struct Book *book, int index);
void show_book_info(struct Book book, int index);
void borrow_book(struct Book *book);
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.18
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;83"
>
문제1
Data 영역 : 전역변수, static
Heap 영역 : 동적할당 ( 프로그래머에 의해 할당되고 해제됨 )
Stack 영역 : 지역변수 ( 자동 할당 및 자동 해제 )
지역변수는 할당할 수록 메모리 주소가 내려가는데, 전역변수가 지역변수보다 주소값이 크게 나오더라고요. 이런게 있다고만 생각하고 다들 넘어가시는게 좋을거 같습니다.
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.18
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;71"
>
문제1
공용체는 통신쪽에서 많이 사용한다고 합니다.
우리가 소스를 짤 때는 A라는 항목을 입력 받으면 B라는 항목을 받지 않아도 될 때 사용하면 메모리를 효율적으로 사용이 가능할 것 같습니다.
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.18
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;229"
>
unique_ptr 소유권 이전하기 부분에서 std::move가 필요한 이유에 대한 퀴즈의 답은 pa를 r-value reference로 만들어서 이동 생성자를 호출해야 하기 때문이라고 생각하면 될까요?
</a>
</div>
<div class="comment-author">
Ryu
<span class="comment-date">
09.17
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;60"
>
문제2
5+5 같이 고려할 사항이 있으므로 나중에...
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.17
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;60"
>
문제1
#include &lt;stdio.h&gt;

struct Book{
char title[30];
char author[20];
char publ[20];
int borrowed;
};

int get_len(char *pa);
void add_book(struct Book (*book)[100], int *index);
void search_book(struct Book (*book)[100], int *index);
void show_book_info(char *name, char *author, char *publisher, int exist, int index);
int compare_string(char *cp1, char *cp2, int len1, int len2);
void borrow_book(struct Book (*book)[100]);

&#x2F;&#x2F;대출 또는 반납할 책 번호가 유효한지 확인 해야함
&#x2F;&#x2F;숫자 데이터만 입력 가능

int main()
{
struct Book book[100];

int order = 0;
int index = 0;

printf(&quot;도서관리 프로그램에 오신것을 환영합니다!\n&quot;);

while(1)
{
printf(&quot;1. 추가 &#x2F; 2. 검색 &#x2F; 3. 대출,반납 &#x2F; 4.종료\n&quot;);
scanf(&quot;%d&quot;, &amp;order);

if(order == 1)
{
add_book(&amp;book, &amp;index);
}
else if(order == 2)
{
search_book(&amp;book, &amp;index);
}
else if(order == 3)
{
borrow_book(&amp;book);
}
else if(order == 4)
{
break;
}
else if(order == 5)
{
for(int i = 0; i &lt; index; i++)
{
printf(&quot;%s\n&quot;, book[i].title);
printf(&quot;%s\n&quot;, book[i].author);
printf(&quot;%s\n&quot;, book[i].publ);
printf(&quot;%d\n&quot;, book[i].borrowed);
}
}
else
{
printf(&quot;알 수 없는 명령어\n&quot;);
}
}

return 0;
}
&#x2F;&#x2F;책 대출
void borrow_book(struct Book (*book)[100])
{
int order = -1;

printf(&quot;1. 대출 &#x2F; 2. 반납 &#x2F; 3. 뒤로가기\n&quot;);
scanf(&quot;%d&quot;, &amp;order);

if(order == 1)
{
int num = -1;
printf(&quot;대출할 책 번호 : &quot;);
scanf(&quot;%d&quot;, &amp;num);

if(book[num]-&gt;borrowed == 1)
{
printf(&quot;이미 대출중 입니다.\n&quot;);
return;
}

book[num]-&gt;borrowed = 1;

printf(&quot;------------------대출완료------------------\n&quot;);
show_book_info(book[num]-&gt;title, book[num]-&gt;author, book[num]-&gt;publ, book[num]-&gt;borrowed, num);
}
else if(order == 2)
{
int num = -1;
printf(&quot;반납할 책 번호 : &quot;);
scanf(&quot;%d&quot;, &amp;num);

if(book[num]-&gt;borrowed == 0)
{
printf(&quot;이미 반납 됐습니다.\n&quot;);
return;
}

book[num]-&gt;borrowed = 0;

printf(&quot;------------------반납완료------------------\n&quot;);
show_book_info(book[num]-&gt;title, book[num]-&gt;author, book[num]-&gt;publ, book[num]-&gt;borrowed, num);
}
}

&#x2F;&#x2F;책 추가
void add_book(struct Book (*book)[100], int *index)
{
printf(&quot;제목 : &quot;);
scanf(&quot;%s&quot;, book[*index]-&gt;title);

printf(&quot;저자 : &quot;);
scanf(&quot;%s&quot;, book[*index]-&gt;author);

printf(&quot;출판사 : &quot;);
scanf(&quot;%s&quot;, book[*index]-&gt;publ);

book[*index]-&gt;borrowed = 0;

printf(&quot;------------------추가완료------------------\n&quot;);
printf(&quot;번호 : %d\n&quot;, *index);
printf(&quot;제목 : %s\n&quot;, book[*index]-&gt;title);
printf(&quot;저자 : %s\n&quot;, book[*index]-&gt;author);
printf(&quot;출판사 : %s\n&quot;, book[*index]-&gt;publ);
if(book[*index]-&gt;borrowed == 0)
{
printf(&quot;대출여부 : 대출가능\n&quot;);
}
else
{
printf(&quot;대출여부 : 대출됨\n&quot;);
}
printf(&quot;--------------------------------------------\n&quot;);
printf(&quot;\n&quot;);

*index = *index + 1;
}

int compare_string2(char *cp1, char *cp2, int len1, int len2)
{
for(int i = 0; i &lt; len1; i++)
{
int j = 0;

if(cp1[i] == cp2[j])
{
int k = i;
int cnt = 0;

while(1)
{
if(k &gt;= len1 || j &gt;= len2) break;

if(cp1[k] == cp2[j])
{
cnt++;
}

k++;
j++;
}

if(cnt == len2)
{
return i;
}
}
}

return -1;
}

&#x2F;&#x2F;책 찾기
void search_book(struct Book (*book)[100], int *index)
{
int order = 0;
int len1 = 0;
int len2 = 0;

int last_idx = *index;

char c[30];

printf(&quot;1. 제목으로 찾기 &#x2F; 2. 저자로 찾기 &#x2F; 3. 출판사로 찾기 &#x2F; 4. 뒤로가기\n&quot;);
scanf(&quot;%d&quot;, &amp;order);

if(order == 1)
{
int cnt = 0;

printf(&quot;제목 : &quot;);
scanf(&quot;%s&quot;, c);

len2 = get_len(c);

for(int i = 0; i &lt; last_idx; i++)
{
printf(&quot;%s-----\n&quot;, book[i]-&gt;title);
len1 = get_len(book[i]-&gt;title);
int result = compare_string2(book[i]-&gt;title, c, len1, len2);

if(result != -1)
{
show_book_info(book[i]-&gt;title, book[i]-&gt;author, book[i]-&gt;publ, book[i]-&gt;borrowed, i);
cnt++;
}
}

if(cnt == 0)
{
printf(&quot;일치하는 정보가 없습니다.\n\n&quot;);
}
}
else if(order == 2)
{
int cnt = 0;

printf(&quot;저자 : &quot;);
scanf(&quot;%s&quot;, c);

len2 = get_len(c);

for(int i = 0; i &lt; last_idx; i++)
{
len1 = get_len(book[i]-&gt;author);
int result = compare_string2(book[i]-&gt;author, c, len1, len2);

if(result == 0)
{
show_book_info(book[i]-&gt;title, book[i]-&gt;author, book[i]-&gt;publ, book[i]-&gt;borrowed, i);
cnt++;
}
}

if(cnt == 0)
{
printf(&quot;일치하는 정보가 없습니다.\n\n&quot;);
}
}
else if(order == 3)
{
int cnt = 0;

printf(&quot;출판사 : &quot;);
scanf(&quot;%s&quot;, c);

len2 = get_len(c);

for(int i = 0; i &lt; last_idx; i++)
{
len1 = get_len(book[i]-&gt;publ);
int result = compare_string2(book[i]-&gt;publ, c, len1, len2);

if(result == 0)
{
show_book_info(book[i]-&gt;title, book[i]-&gt;author, book[i]-&gt;publ, book[i]-&gt;borrowed, i);
cnt++;
}
}

if(cnt == 0)
{
printf(&quot;일치하는 정보가 없습니다.\n\n&quot;);
}
}
}

void show_book_info(char *name, char *author, char *publisher, int exist, int index)
{
printf(&quot;--------------------------------------------\n&quot;);
printf(&quot;번호 : %d\n&quot;, index);
printf(&quot;제목 : %s\n&quot;, name);
printf(&quot;저자 : %s\n&quot;, author);
printf(&quot;출판사 : %s\n&quot;, publisher);
if(exist == 0)
{
printf(&quot;대출여부 : 대출가능\n&quot;);
}
else
{
printf(&quot;대출여부 : 대출됨\n&quot;);
}
printf(&quot;--------------------------------------------\n&quot;);
printf(&quot;\n&quot;);
}

int compare_string(char *cp1, char *cp2, int len1, int len2)
{
if(len1 == len2)
{
for(int i = 0; i &lt; len1; i++)
{
if(cp1[i] != cp2[i])
{
return -1;
}
}

return 0;
}

return -1;
}

int get_len(char *pa)
{
int len = 0;

while(*pa != &#x27;\0&#x27;)
{
len++;
pa++;
}

return len;
}
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.17
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;55"
>
문제2
강좌에서 포인터를 이용해 구조체 주소를 받을 수 있는것으로 보아 배열을 인자로 받듯이 동일하게 받으면 될거 같습니다.
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.17
</span>
</div>
</div>

<div class="comment-box">
<div class="comment-content">
<a
class="comment-link"
href="&#x2F;55"
>
문제1
구조체는 멤버들의 집합이니 구조체 안에 구조체 또한 가능할 것 같습니다.
</a>
</div>
<div class="comment-author">
C언어 박살
<span class="comment-date">
09.17
</span>
</div>
</div>

</div>
</div>
</div>
<div class="item">
<div class="item-text">
<script
async
src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
></script>
<!-- Modoocode-front-page -->
<ins
class="adsbygoogle"
style="display: block"
data-ad-client="ca-pub-6608926154840997"
data-ad-slot="8048150950"
data-ad-format="auto"
data-full-width-responsive="true"
></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</div>
</div>
</main>
</body>
</html>

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
<script>
var ctx = document.getElementById("visitors").getContext('2d');
ctx.canvas.height = ctx.canvas.width / 2.7;

var counts = [["20250912","640"],["20250913","324"],["20250914","358"],["20250915","796"],["20250916","766"],["20250917","765"],["20250918","679"],["20250919","225"]];
var count = [];
var labels = [];

for (var i = 0; i < counts.length; i++) {
count.push(counts[i][1]);
var label = counts[i][0].substr(4);
label = label.slice(0, 2) + '.' + label.slice(2);
labels.push(label);
}
var visitor_chart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
data: count,
borderColor: 'rgba(0, 190, 190)',
backgroundColor: 'rgba(0, 190, 190, 0.1)',
}],
},
options: {
legend: {
display: false
},
title: {
display: true,
text: '일일 방문자 수'
},
scales: {
yAxes: [{
ticks: {
min: 0,
stepSize: 400
}
}]
}
}
})
</script>

Ads.Txt Alerts - A trading name of Red Volcano Limited

Waterloo Buildings, Second Floor Rear, 53 London Road, Southampton, Hampshire, United Kingdom, SO15 2AD

© Red Volcano 2020. All Rights Reserved.