|
-
Jan 7th, 2003, 09:47 PM
#1
Thread Starter
Member
A Little Help!?!?
Hey people, I need some help, I got a new book, and it tells right off the bat to do this to write out all the ASCII characters:
PHP Code:
#include <iostream>
main <void>
{
unsigned char ASCIIValue = 0;
while (ASCIIValue < 256)
std::cout.put (ASCIIValue);
ASCIIValue ++;
return 0;
}
Ok so why the hell dose it not work, this book is using VC++, and im using the same complier, so could osme one plz tell me ***?
Gives errors do to ";" not being behind < or something.
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 8th, 2003, 12:40 AM
#2
transcendental analytic
int main(void)
instead of
main <void>
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 8th, 2003, 12:44 AM
#3
Hyperactive Member
Re: A Little Help!?!?
Code:
#include <iostream>
int main (void)
{
unsigned char ASCIIValue = 0;
while (ASCIIValue <= 255)
{
std::cout.put (ASCIIValue);
ASCIIValue ++;
}
return 0;
}
You forgot to put curly brackets for the while loop
Edited: the upper limit of unsigned char is 255
-
Jan 8th, 2003, 04:50 AM
#4
If what you first posted is what your book told you to do then throw it away.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 8th, 2003, 06:46 AM
#5
Monday Morning Lunatic
Or send it to me so I can televise its ritual destruction, followed by posting the pieces to the publisher.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 8th, 2003, 10:42 AM
#6
How about ritually destructing the author?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 8th, 2003, 02:53 PM
#7
Thread Starter
Member
lol yeah it was a type from the book..
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 8th, 2003, 02:54 PM
#8
Thread Starter
Member
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 8th, 2003, 04:16 PM
#9
Bad enough that a c++ book gives main no return type. That's a very bad manner that shouldn't even be started.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 8th, 2003, 06:31 PM
#10
Thread Starter
Member
I know what you mean, it should have been left main ().
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 8th, 2003, 07:40 PM
#11
Frenzied Member
No he means the return type, like
I guess.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Jan 8th, 2003, 10:52 PM
#12
Thread Starter
Member
I know I meant the return type, thats why I said leave it empty instead of putting void main ( ) main (void)
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 05:26 AM
#13
Monday Morning Lunatic
Leave what empty?
The definition is:
Code:
int main(int argc, char **argv);
You can miss off argv, or argc AND argv. Since we're talking about C++, a blank argument list () is acceptable. In C, if main did not require arguments, it should be given as:because in C, a blank argument list means it can take any number, rather than taking none, as in C++.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 9th, 2003, 05:44 AM
#14
transcendental analytic
it could still have been a typo, because there's return 0;
what does the other examples in the book have?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 9th, 2003, 06:11 AM
#15
Don't they ever take a look at their books?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|