Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > simple ? repost

Reply
Thread Tools

simple ? repost

 
 
Boris Glawe
Guest
Posts: n/a
 
      07-30-2003
Mike Lundell wrote:
> 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)

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

 
Reply With Quote
 
 
 
 
Mike Lundell
Guest
Posts: n/a
 
      07-30-2003
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)
 
Reply With Quote
 
 
 
 
Mike Lundell
Guest
Posts: n/a
 
      07-30-2003

> Before reposting hundreds of times, you
> should have looked for answers... my


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
 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      07-30-2003

"Mike Lundell" <workingmike_no@spam_hotmail.com> wrote in message
news:...
> 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


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


 
Reply With Quote
 
Thomas Matthews
Guest
Posts: n/a
 
      07-30-2003
John Harrison wrote:

> "Mike Lundell" <workingmike_no@spam_hotmail.com> wrote in message
> news:...
>
>>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

>
>
> 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
>
>


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:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
REPOST - Please can someone help me with a simple cookie question Alan Silver ASP .Net 0 10-06-2005 02:55 PM
Repost: D-Link wireless PCI needs rescan every boot Monte Grant Wireless Networking 0 12-23-2004 08:59 PM
Newbie cgi problem - repost Little Monster Perl 3 05-06-2004 06:58 PM
Mystery Repost bjh Perl 0 01-13-2004 07:59 PM
i repost the message, because i never solved the problem :'( TechMan Cisco 3 07-23-2003 02:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57