변수 값에 변수 값 넣기(?)는 어떻게 하는거죠 c 언어

mudori의 이미지

다름이 아니라 아래와 같이 하고 싶은데 안됩니다.

char a=bbbb;
char b;

b="adsfasdadasd a adsasdfasdf";

중간에 a 변수를 넣고 싶은데 그냥 a를 찍어 버리네요.

간단할것 같은데 모르겠습니다. 도움좀..

Prentice의 이미지

char에 string을 넣으시려는 것인가요..? ^^;;

ㅡ,.ㅡ;;의 이미지

자료형이 무엇인지 이해못하셨군요.


----------------------------------------------------------------------------

mudori의 이미지

php 개념으로 하다보니 프로그램 실력이 엉망이네요.
그냥 변수안에 변수 값을 넣는건데.. 개념이 허접 개념이라서..

neogeo의 이미지

우선 C 언어의 Data type 부터 책으로 차근 차근 살펴보심이 좋겠군요.

char 은 문자열아닌 1 캐릭터를 보관하는 Data type 입니다.

즉 1 Byte 짜리 이지요. ( 물론 꼭 그런것은 아닙니다. 일단 처음엔 그렇구나 라고만 알아두시면 문제 없을것 입니다. )

php 는 특별히 Data type 없이 아무 변수나 마찬가지 이지요.

C 언어는 Data type 을 매우 엄격히 지키는 언어 입니다.

항상 주의를 하셔야 합니다.

원하시는 변수에 값을 넣는 것은 문자가 아닌 문자열을 넣는 것이므로

적어도 메모리공간을 확보하고 넣어야 합니다.

C 언에서 string ( 문자열 ) 을 다루는것은 공부를 자세히 해두셔야

나중에 실 수 하시는 일이 없을 것 입니다.

Neogeo - Future is Now.

xster의 이미지

  char a[] = "bbbbb";
  char b[256];

  snprintf(b, 255, "asdfasdfasdfsadf %s asdfasdfasdf", a);

일단은 위에 처럼 하시면 되겠지만 사용하시는 구체적인 내용에 따라 실제 구현은 많이 달라질 수 있습니다.
c는 변수의 형이 존재하므로 php에서처럼 간단하게는 안 됩니다.
기본적인 c 입문서를 먼저 읽어 보세요.

mudori의 이미지

감사합니다. .. 언어를 이것 저것 대충 대충 알다보니 이런 일이 발생하네요.. 공부좀 해야겠네요.. ^^

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.