>>7
Because you didn't know how to use scanf? Did you read a fucking microsoft users manual?
Name:
Anonymous2009-06-12 7:33
Op here.
Sorry >>3 and >>4.
It isn't my homework i learn it for fun >>2.
Thanks >>7 and >>8 but it still fails to compile it.
I'll try to repost it using [code] tags (now after i fixed the semicolon) :
[code]
#include <iostream>
#include <ctime>
#include <conio.h>
using namespace std;
int main(void){
int UPPER_LIMIT;
int random;
int userguess;
char playAgain;
srand(static_cast<unsigned int>(time(0)));
random = rand()%20+1;
do{
while(userguess !== random){
cout << "Please enter a number between 1 - 20: ";
cin >> userguess;
if(userguess == random){
cout << "wow good job you guessed right." <<endl;
}
else if(userguess > random){
cout << "that number is too low" <<endl;
system("CLS");
}
else if(userguess < random){
cout << "that number is too high" <<endl;
system("CLS");
}
}
cout << "Do you wish to play again? y//n: ";
cin >> playAgain;
>>11
No, because I was about 14 and I just wanted to make games, so I found a tutorial about game programming in C++, and at the time I couldn't care less about what I was using as long as I'd learn programming.
Why don't you use the compiler's output to determine what's wrong? I'm sure it gives you helpful messages including the line number at which it finds an error. I found another obvious mistake, but this time try to find it yourself.
Name:
Anonymous2009-06-12 7:51
>>12
I found two syntax errors, actually.
Also you don't need to escape /, if that was what you wanted to do in "Do you wish to play again? y//n: ".
And what kind of editor are you using?
Name:
Anonymous2009-06-12 8:21
3rd attempt to repost with tags:
[code]
#include <iostream>
#include <ctime>
#include <conio.h>
using namespace std;
int main(void){
int UPPER_LIMIT;
int random;
int userguess;
char playAgain;
srand(static_cast<unsigned int>(time(0)));
random = rand()%20+1;
do{
while(userguess !== random){
cout << "Please enter a number between 1 - 20: ";
cin >> userguess;
if(userguess == random){
cout << "wow good job you guessed right." <<endl;
}
else if(userguess > random){
cout << "that number is too low" <<endl;
system("CLS");
}
else if(userguess < random){
cout << "that number is too high" <<endl;
system("CLS");
}
}
cout << "Do you wish to play again? y//n: ";
cin >> playAgain;
} while(tolower(playAgain == 'y');
getch();
return 0;
}
Thanks >>15, i hope i did it right this time. Also i don't have line numbers and i don't understand the compiler's output:
"in function 'int main()':
line 17 - expected primary-expression before '=' token
line 42 - expected ')' before ';' token"
Hey wait a second.. Now that i look at it i really did forgot a bracket in line 42. You were right >>15.. But this one output was simple to understand, what does the 2 other lines means?
>>16 Is BloodShed or mingw32 editors? If not i'm not sure what editor it is, sorry.
!==
This is not PHP. If you really can't figure this out I'm going to have to ask you to go [i]back to /preschool/ please.
Name:
Anonymous2009-06-12 9:23
>>17
Why don't your try to figure out what
line 17 - expected primary-expression before '=' token
line 42 - expected ')' before ';' token"
means?
Name:
Anonymous2009-06-12 9:39
>>18 Op here. Shoul i nt write "!=="? What should i write instead? >>19 read all of post >>17 in the end i said i figured the bracket missing in line 42 but the other output of the compiler were not understandable for me, what do they mean?
>>21 Op here. dentending on waht?? id on't GET IT?!!
Name:
Anonymous2009-06-12 9:43
ITT: OP trolls you all
Name:
Anonymous2009-06-12 9:45
>>22
YHBT, it should be !=
This thread was exactly the pick-me-up I needed this morning :)
Name:
Anonymous2009-06-12 10:03
Now that I think about it, !== makes much more sense than !=, which should be more like bitwise negation and assignment, given operators like += and *=.
Yet another example of why sepples sucks so fucking much.
Name:
Anonymous2009-06-12 10:35
>>25
All you have said applies to C, Java, Javascript as well. What now faggot. YHBT.
>>25
Is bitwise negation a task you do often enough, that you think it deserves an operator?
The reason we use !== instead of != is the same reason we use cd/rm/cp instead of changedir/remove/copy, it saves some marginal amount of typing and screen space back when it was more of an issue. Some people advocate <>, but I don't think it works particularly well for non-numbers.
Name:
Anonymous2009-06-12 10:53
Is bitwise negation a task you do often enough, that you think it deserves an operator?
No. It is not a questions of whether it is done often enough. There are hosts of operators standard in C/C++ that don't get used often. It is a question of a consistent interpretation of symbols, rather than an ad hoc implementation.
The reason we use !== instead of != is the same reason we use cd/rm/cp instead of changedir/remove/copy, it saves some marginal amount of typing and screen space back when it was more of an issue.
Code is read more than it is written. This excuse has never made sense.
>>33
The first is also infinitely incorrect. a = !b implies equality of a with b's complement, which is only a one way guarantee of inequality. Really it should be, a ⊃ (a ∩ b).
>>40
I don't see any conflict of interest in both responding seriously and saging. In fact, from the way you are touting this everywhere when /prog/ is still trying to match the quality of our Japanese sister board, I think you would be best to head back to where you came from, namely, /g/.
Name:
Anonymous2009-06-12 12:40
>>42 >>43
don't sage if you're replying to the thread. sage if you are saying 'fuck this thread, go to /r/' or whatever. idiot.
Name:
Anonymous2009-06-12 12:41
•= only makes sense if • is a binary operator, since a •= b
stands for a = a • b
Therefore != would be inconsistent with the rest of assignment operators, since a = a ! b doesn't make sense. IHPBT,SNCBTS
>>44
I'll ask you again nicely. You only just arrived here and I think in retrospect we can all see it would be best for you to depart back where you came from. Thank you for your time.
Name:
Anonymous2009-06-12 12:44
And another thing, why don‘t **a and //a behave consistently with ++a and --a? Fucking sepples.
because **a is a pointer to a pointer to variable of type a.
And //a would signal comment line.
++ and -- are used for increment and decrement in loops.
Name:
Anonymous2009-06-12 14:09
>>47
This is a good question. When you come down to it, the C family of languages is simply an ad hoc, grab-bag, random assortment of shift-characters masquerading as serious programming, with no internal consistency, context-sensitive grammar, and sad lack of referential transparency. It's one thing for English, Japanese, or !Kung to be all fucked up, they're natural languages that evolved over thousands of years, but programming languages are intentionally created by people. There's no excuse.
>>52
You see, I was actually pointing out what a worthless idea consistency is in this context. Since it hinders expressiveness by adding bloat that no one has any use for.
>>60
I should really finish my Fjölnir interpreter. It could do most of that simple program‚ it❜s just missing a lot of "GRUNNUR" functions and the whole linking of modules thing. (Also innútbreyta.)
Are you using Snorri Agnarsson's compiler‚ or one of your own devising?
Name:
Anonymous2009-06-14 18:44
>>62
I‘m using FJOLNIR2.EXE for now. I‘f been planning to make my own compiler (an LLVM frontend), but all I have written is the parser. I was going to post it on /prog.git/ once it could dump a syntax tree. I‘m quite INEXPERT at compilers though, so working out code generation will probably be harder than deciphering the docs.
>>63
I saw it when you posted it, and I was quite impressed; I guess I didn‘t respond though. Probably because I don‘t have a 32-bit windows box to run it on, and I suspect it wouldn‘t run under wine. I can more-or-less see what it‘s doing, though.
Well, I guess I should post mine somewhere, since it can dump a syntax tree. It‘s written in dead dog¹, is disgusting in a porcine fashion, and generates a 5MB executable², but it works.
Have a look at http://filebin.ca/xvfkdb/fjolnir.tar.gz if you‘re bored and understand Haskell. I've only implemented the parts of "GRUNNUR" that I've been interested in so far, which isn't a great deal.
¹ ;_;.
² Then again, most Haskell programs does this.
>>65 I saw it when you posted it, and I was quite impressed; I guess I didn‘t respond though. Probably because I don‘t have a 32-bit windows box to run it on, and I suspect it wouldn‘t run under wine. I can more-or-less see what it‘s doing, though.
:)
Here, have a screenshot: http://i42.tinypic.com/2csj910.jpg
The data is the number of pixels to run before each color switch, and most of the actual code deals with stuffing pixels into the right bit positions on a black-and-white bitmapped display (necessary to get that kind of resolution in 16-bit DOS).
Have a look at http://filebin.ca/xvfkdb/fjolnir.tar.gz if you‘re bored and understand Haskell. I've only implemented the parts of "GRUNNUR" that I've been interested in so far, which isn't a great deal.
This is way beyond my Haskell ability, but I‘ll definitely look it over.