CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Oct 2009
    Posts
    39

    Arrow character declaraton

    why i can't declare my character string as

    (char*) care=0;

    and what is the mearning of
    char& *care ? because i would like to define a pointer to char type that also is a reference.

    thank you

  2. #2
    Join Date
    Dec 2008
    Posts
    144

    Re: character declaraton

    Quote Originally Posted by Dragon5 View Post
    why i can't declare my character string as
    (char*) care=0;
    Well, the "(char*)" is not declaration. It's a casting operator.

  3. #3
    Join Date
    Oct 2009
    Posts
    39

    Re: character declaraton

    sorry but how do you know that ?

  4. #4
    Join Date
    Feb 2005
    Posts
    2,160

    Re: character declaraton

    It's part of the C standard (and hence works in C++, but there are other ways to cast in C++).

  5. #5
    Join Date
    Oct 2009
    Posts
    39

    Re: character declaraton

    i think it is atype definition and the compiler doesn't allow it to define like that

    because

    char a;
    char*a;
    only differentiates by an *

    so i mean to comprehend why a pair of parentheses make such a difference to the compiler, how ?

  6. #6
    Join Date
    Feb 2005
    Posts
    2,160

    Re: character declaraton

    Because that's what compilers do? I don't understand what you are asking. Maybe you should back up a bit. What are you trying to do?

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: character declaraton

    Quote Originally Posted by Dragon5 View Post
    i think it is atype definition and the compiler doesn't allow it to define like that

    because

    char a;
    char*a;
    only differentiates by an *

    so i mean to comprehend why a pair of parentheses make such a difference to the compiler, how ?
    Because that's how the language works.

    You know the difference between your two declarations, right? One is a char, and one is a pointer.

    You can declare char* a = 0 if you like.

  8. #8
    Join Date
    Oct 2009
    Posts
    39

    Re: character declaraton

    Quote Originally Posted by hoxsiew View Post
    I don't understand what you are asking. Maybe you should back up a bit.
    what does "back up a bit" really mean ?
    i have been waiting long enough to get such replies, my waiting time sure can be doubled till i get what i want.


    ok, i won't lengthen this thread.

  9. #9
    Join Date
    Feb 2005
    Posts
    2,160

    Re: character declaraton

    I'm not trying to be deliberately obtuse, but I can't figure out what it is that you are asking? I thought a little background in your overall goal might help me understand your dilemma.

  10. #10
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: character declaraton

    Quote Originally Posted by Dragon5 View Post
    what does "back up a bit" really mean ?
    i have been waiting long enough to get such replies, my waiting time sure can be doubled till i get what i want.


    ok, i won't lengthen this thread.
    Sometimes when you're knew to the language and know a few tools or tricks, you want to apply that knowledge and make it work for every problem. Back up a bit means slow down a little, explain what you're trying to do and see if you're on the right track before plowing ahead.

  11. #11
    Join Date
    Oct 2009
    Posts
    39

    Re: character declaraton

    sorry i am bad at the language,
    i can understand only the narrow meaning,
    i have no idea of metaphor or word use to imply different things, that is why i ask him.
    i think you and he share the same view and attitude over his own particular post toward me, which is quite odd but i won't care to ask for more.

  12. #12
    Join Date
    Jun 2008
    Posts
    592

    Re: character declaraton

    look at this http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B

    it talks about operators. it should help you.
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  13. #13
    Join Date
    Jul 2009
    Posts
    45

    Re: character declaraton

    Every1 here is to help you, dragon5

    (char*) is language defined, such use to declaring object type is not allowed

  14. #14
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: character declaraton

    Quote Originally Posted by Dragon5 View Post
    sorry i am bad at the language,
    i can understand only the narrow meaning,
    i have no idea of metaphor or word use to imply different things, that is why i ask him.
    i think you and he share the same view and attitude over his own particular post toward me, which is quite odd but i won't care to ask for more.
    Just trying to help. Your questions aren't exactly clear. Sometimes knowing more about what you're trying to do can help us get you a better answer.

  15. #15
    Join Date
    Jul 2009
    Posts
    45

    Re: character declaraton

    Quote Originally Posted by hoxsiew View Post
    I'm not trying to be deliberately obtuse, but I can't figure out what it is that you are asking? I thought a little background in your overall goal might help me understand your dilemma.
    It's nice of you to "help" him

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured