> For the complete documentation index, see [llms.txt](https://krjaeh0.gitbook.io/j-log/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krjaeh0.gitbook.io/j-log/programming/languages/c-and-c++/c-fundamentals/strings.md).

# strings

{% code title="strings.c" %}

```c
#include <stdio.h>
/*must include*/
#include <string.h>

void concept(void)
{
    /*Defining*/
    char *name = "Jung Jaeho";
    /*
    same as
    char name[] = "Jung Jaeho";
    char name[11] = "Jung Jaeho";
    */

    /*string formatting with printf*/
    int age = 27;
    printf("%s is %d years old.\n", name, age);

    /*string Length*/
    printf("%lu\n", strlen(name));

    /*string comparison*/
    if (strncmp(name, "Jung Jaeho", 10) == 0)
    {
        printf("Helle, Jaeho!\n");
    }
    else
    {
        printf("You are not Jaeho.\n");
    }

    /*String Concatenation*/
    char First_name[20] = "Jung";
    char Last_name[20] = "Jaeho";

    strncat(First_name, Last_name, 5);
    printf("%s\n", First_name);
    strncat(First_name, Last_name, 20);
    printf("%s\n", First_name);
}

void exercise(void)
{
    // 포인터 표기법을 사용하여 문자열 first_name을 John 값으로 정의하고, 로컬 배열 표기법을 사용하여 문자열 last_name을 Doe 값으로 정의합니다.
    /* define first_name */
    char *first_name = "John";
    /* define last_name */
    char last_name[] = "Doe";
    char name[100];

    last_name[0] = 'B';
    sprintf(name, "%s %s", first_name, last_name);
    // printf("test: %s\n",name);
    if (strncmp(name, "John Boe", 100) == 0)
    {
        printf("Done!\n");
    }
    name[0] = '\0';
    strncat(name, first_name, 4);
    strncat(name, last_name, 20);
    printf("%s\n", name);
}

int main(void)
{
    concept();
    exercise();
    return 0;
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://krjaeh0.gitbook.io/j-log/programming/languages/c-and-c++/c-fundamentals/strings.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
