simple ? repost

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Lundell

    #1

    simple ? repost

    lemee try this again, for today's date :)...

    ..............

    what's wrong with this, and .. can you not declare "char" variables?

    #include <iostream>

    int main()
    {
    int a = "* * * * * * * *\n";
    std::cout << a;
    return EXIT_SUCCESS;
    }

    thx

    (p.s. i reposted because the date on my comp was for yesterday, and i didn't
    know if ppl would see the post so i changed the date and now i'm
    reposting.. sorry if someone get's mad about that)
  • Boris Glawe

    #2
    Re: simple ? repost

    Mike Lundell wrote:[color=blue]
    > lemee try this again, for today's date :)...
    >
    > .............
    >
    > what's wrong with this, and .. can you not declare "char" variables?
    >
    > #include <iostream>
    >
    > int main()
    > {
    > int a = "* * * * * * * *\n";
    > std::cout << a;
    > return EXIT_SUCCESS;
    > }
    >
    > thx
    >
    > (p.s. i reposted because the date on my comp was for yesterday, and i didn't
    > know if ppl would see the post so i changed the date and now i'm
    > reposting.. sorry if someone get's mad about that)[/color]
    Before reposting hundreds of times, you
    should have looked for answers... my
    answer arrived two minutes before your
    third repost :-)

    Btw.: You can also try to cancel your
    posts if something went wrong !

    greets Boris

    Comment

    • Mike Lundell

      #3
      Re: simple ? repost

      [color=blue]
      > Before reposting hundreds of times, you
      > should have looked for answers... my[/color]

      thx lol, i just installed mndrk, and i'm new to it. including this
      newsreader. anyway.. just call me noob and go on with ur day :)

      Comment

      • John Harrison

        #4
        Re: simple ? repost


        "Mike Lundell" <workingmike_no @spam_hotmail.c om> wrote in message
        news:vif80dahf3 331b@corp.super news.com...[color=blue]
        > lemee try this again, for today's date :)...
        >
        > .............
        >
        > what's wrong with this, and .. can you not declare "char" variables?
        >
        > #include <iostream>
        >
        > int main()
        > {
        > int a = "* * * * * * * *\n";
        > std::cout << a;
        > return EXIT_SUCCESS;
        > }
        >
        > thx[/color]

        What's wrong? "* * * * ... is not an integer.

        Can you declare char variables? Of course

        #include <iostream>

        int main()
        {
        char a = '*';
        std::cout << a;
        }

        However char variables hold a single char, I'm guessing you want a string.

        #include <iostream>
        #include <string>

        int main()
        {
        std::string a = "* * * * *\n";
        std::cout << a;
        }

        john


        Comment

        • Thomas Matthews

          #5
          Re: simple ? repost

          John Harrison wrote:
          [color=blue]
          > "Mike Lundell" <workingmike_no @spam_hotmail.c om> wrote in message
          > news:vif80dahf3 331b@corp.super news.com...
          >[color=green]
          >>lemee try this again, for today's date :)...
          >>
          >>........... ..
          >>
          >>what's wrong with this, and .. can you not declare "char" variables?
          >>
          >>#include <iostream>
          >>
          >>int main()
          >>{
          >> int a = "* * * * * * * *\n";
          >> std::cout << a;
          >> return EXIT_SUCCESS;
          >>}
          >>
          >>thx[/color]
          >
          >
          > What's wrong? "* * * * ... is not an integer.
          >
          > Can you declare char variables? Of course
          >
          > #include <iostream>
          >
          > int main()
          > {
          > char a = '*';
          > std::cout << a;
          > }
          >
          > However char variables hold a single char, I'm guessing you want a string.
          >
          > #include <iostream>
          > #include <string>
          >
          > int main()
          > {
          > std::string a = "* * * * *\n";
          > std::cout << a;
          > }
          >
          > john
          >
          >[/color]

          The OP may also want a collection of characters terminated by a NULL,
          IOW, a C style string:
          #include <iostream>
          using std::cout;

          int main(void)
          {
          char ernie[] = "Ernie";
          const char * const fred = "Fred";
          cout << ernie << '\n'
          << fred << '\n';
          return 0;
          }

          --
          Thomas Matthews

          C++ newsgroup welcome message:

          C++ Faq: http://www.parashift.com/c++-faq-lite
          C Faq: http://www.eskimo.com/~scs/c-faq/top.html
          alt.comp.lang.l earn.c-c++ faq:

          Other sites:
          http://www.josuttis.com -- C++ STL Library book

          Comment

          Working...