Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++

Name: Anonymous 2009-06-12 6:31

Hello /prog/.

I know very little about C++. and my only other experience with programming is a calculator in freeBasic.

I studied how to programm a guessing game from the internets but my 4.9.9.2 Dev C++ fail to compile it.

this is what i wrote:

#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;
}

PLEEAASE HAAALP /PROG/.
Thanks in advance.

Name: Anonymous 2009-06-12 12:34

assignment <- or -> (infix)
= should only be a comparison, not assignment

/THRAD

Name: Anonymous 2009-06-12 12:36

>>40
back to /b/ with you

Name: Anonymous 2009-06-12 12:38

>>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: Anonymous 2009-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: Anonymous 2009-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

Name: Anonymous 2009-06-12 12:43

>>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: Anonymous 2009-06-12 12:44

And another thing, why don‘t **a and //a behave consistently with ++a and --a?  Fucking sepples.

Name: Anonymous 2009-06-12 12:44

>>45
NYJMUS

Name: Anonymous 2009-06-12 12:49

>>40
get out of here dumb dumb.

Name: Anonymous 2009-06-12 12:50

>>48
Shortcuts?

Name: Anonymous 2009-06-12 12:51

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: Anonymous 2009-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.

Name: Anonymous 2009-06-12 14:32

and a sad lack of referential transparency
C
a systems programming language
I lol'd

Name: Anonymous 2009-06-12 15:05

>>52
go back to bed

Name: >>47 2009-06-12 16:04

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

Name: >>52 2009-06-12 17:01

>>55
WOW YOU DON'T SAY

Name: Anonymous 2009-06-13 5:48

It's me - Op again, thanks so much /prog/!

Btw >>22 wasn't me and >>23 is wrong.
But i guess i don't mind >>22 said he was me cause thanks to him >>24 pointed out what my mistake was.

I'm sorry i was so slow! I just now figured i needed to do "!="
instead of "!==" (thanks >>24).

Thanks alot /prog/ you win much!

Name: Anonymous 2009-06-14 1:10

<code>
#include <iostream>
#include <ctime>
#include <conio.h>
using namespace std;

int main(){

    int UPPER_LIMIT;
    int random;
    int userguess;
    char playAgain;
    random = rand()%20+1;

    do
    {
        userguess = 0;
        random = rand()%20+1;

        while(userguess != random)
        {

            cout << "Please enter a number between 1 - 20: ";
            cin >> userguess;

            if(userguess == random)
            {
                cout << "Wow, good job, you guessed right.\nDo you wish to play again? [ y / n ]: ";
                cin >> playAgain;
                cin.get();
            }

            else if(userguess > random)
            {
                cout << "That number is too high." << endl;
                cin.get();
            }

            else if(userguess < random)
            {
                cout << "That number is too low." << endl;
                cin.get();
            }
        }

    } while( playAgain == 'y' );
}
</code>

fix'd

Name: Anonymous 2009-06-14 1:27

ITT sepplesfags prove that they're too stupid to understand simple [b][i][o][u]BBCODE[/u][/o][/i][/b].

Name: Anonymous 2009-06-14 1:45

Dear OP, I fixed you're code.

"dagame" < aðal {
aðal -> stef(;)
    staðvær goal, guess, left := 10
    stofn
        goal := slembi(;) % 1000 + 1,
        lykkja
            \skrifafjöl left,
            \skrifastreng " guesses left\nGuess: ",
            guess := lesa(;),
            ef ekki \ertala guess þá
                \skrifastreng "wat\n"
            annarsef guess < goal þá
                \skrifastreng "Too low\n",
                left := left - 1
            annarsef guess > goal þá
                \skrifastreng "Too high\n",
                left := left - 1
            annars
                \skrifastreng "You won!\n",
                út
            eflok,
            ef left <= 0 þá
                \skrifastreng "You lost ;(\n",
                út
            eflok
        lykkjulok
    stofnlok
}
*
!{
slembi -> stef(;)
    innflutt sædi
    stofn
        ef ekki sædi þá
            sædislembi(;)
        eflok,
        sædi := sædi * 649 + 1801 + sædi / 1023
    stofnlok

sædislembi -> stef(;)
    innflutt sædi
    staðvær k,m,s,i
    stofn
        sækjatíma(k,m,s;),
        sædi := k*3600 + m*60 + s,
        fyrir(i := 0; i < 10; i := i+1) lykkja
            slembi(;)
        lykkjulok
    stofnlok
}
*
{ sædi -> breyta }
*
"GRUNNUR"
;

Name: Anonymous 2009-06-14 2:30

>> 28
/=

Name: Anonymous 2009-06-14 15:13

>>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: Anonymous 2009-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.

Also, I‘m sad that nobody acknowledged http://dis.4chan.org/read/prog/1244233849/18.  Please take a look at it if you have time.

Name: Anonymous 2009-06-14 19:30

>>63
I acknowledge http://dis.4chan.org/read/prog/1244233849/18. Please be less sad now.

Name: Anonymous 2009-06-14 19:40

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

$ ./Main
"GRUNNUR"> 1+2+3+4+5+6
(((((1 + 2) + 3) + 4) + 5) + 6)
21
"GRUNNUR"> \hali \haus \haus [1,2,3,4,5,6]
(\hali (\haus (\haus [1,2,3,4,5,6])))
Desugared: (\hali (\haus (\haus (1 : (2 : (3 : (4 : (5 : (6 : [])))))))))
----
3
"GRUNNUR"> fyrir(x := 1, y := 0; x <= 10; x := \stækka x) lykkja y := y + x lykkjulok
fyrir((x := 1),(y := 0);(x <= 10);(x := (\stækka x)))  lykkja (y := (y + x)) lykkjulok
55
"GRUNNUR">█

Name: Anonymous 2009-06-14 23:09

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

Name: Anonymous 2009-06-15 12:27

>>66
http://i42.tinypic.com/2csj910.jpg
I "GRUNNUR"'d.

Apparently I got \hali and \haus the wrong way round when I actually added them to my code. Oops. There's probably a lot of things like that.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List