이 argument의 뜻은 뭔가요? argNewFromArgv (char* const* cons

jongsuknim의 이미지

소스를 보던중 이런 함수가 있던데.. 여기서 argv가 뜻하는게 뭔가요? 이런거 처음 보네요..
extern Arguments* argNewFromArgv (char* const* const argv)

또 다른건..
extern Arguments* argNewFromString (const char* const string)

Fe.head의 이미지

extern Arguments* argNewFromArgv (char* const* const argv);

char* const* const argv

char ** argv 와 비슷하지만

argv 값을 바꿀수 없고
*argv 의 값또한 바꿀수 없다.

결국 바꿀수 있는것은
**argv 값

argv = {"arc", "cdefsdg"}; // 불가
argv++; // 불가
*argv = "abc"; // 불가
(*argv)++; // 불가

(*argv)[0]) = '1'; // 가능

const 는 상수 한정자(? 맞나)입니다.

const int i = 0;
i = 100;          // Error

int i = 0;
int j = 1;
const int * p = &i;      // == int const * p = &i;

*p = 100;      // Error
p = &j;           // 정상

int i = 0;
int j = 1;
int * const p = &i;

*p = 100;      // 정상
p = &j;           // Error

고작 블로킹 하나, 고작 25점 중에 1점, 고작 부활동
"만약 그 순간이 온다면 그때가 네가 배구에 빠지는 순간이야"

익명 사용자의 이미지

const를 이해하는 방법입니다.

1. const는 무조건 자기 왼쪽에 있는걸 상수로 만듭니다.
2. 왼쪽에 아무것도 없다면 오른쪽에 있는걸 상수로 만듭니다.

딱 두가지만 알고 계시면 됩니다. 사실 1번이 다죠. 왼쪽에 없으면 그냥 오른쪽거랑 묶으면 되니까 말입니다.

char const temp;
const char temp;

그래서 위의 두개는 같습니다. 좀 더 복잡해 보이는것으로 가보죠.

const char* temp; (char const * temp와 같습니다)

왼쪽에 있는 char가 상수라는 말입니다. *는 상수가 아니죠. 그래서 temp가 가르키는 값을 바꿀수는 없지만 다른걸 가르키도록 바꿀수는 있습니다.

char * const temp;

이제 쉽죠? const 왼쪽에 있는 *가 상수라는 말입니다.
*temp = 'c' 처럼 char를 바꿀수는 있지만 *가 상수라 temp에 다른 포인터를 넣을 수는 없습니다.

위의 예를 보죠. char * const * const argv 입니다. 왼쪽에 있는 * 두개가 상수라는 말입니다. 결국 상수가 아닌건 char 하나죠.

ps. const는 일관성없는 c문법의 대표주자중 하나라고 생각합니다. 물론 char* ptr, chr; 과 같은거에 비할바는 아니지만, 이해를 어렵게 만드는 한 요소임을 부정하기는 어렵죠.

.neuk

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.