Computing.Net > Forums > Programming > C help plz

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C help plz

Reply to Message Icon

Name: Edgar
Date: December 29, 2001 at 11:58:57 Pacific
Comment:

i`m working on program, well it`s a game really, it`s call AZAR this game have to generate number between 1 to 6 just like a cast. Each player(dicer) have the chance to cast until they reach 15 point or higher whoever reach that score win the game.

help!!!!!!

pd sorry about my english grammar
by the way only 4 player can play that game



Sponsored Link
Ads by Google

Response Number 1
Name: Bob
Date: December 30, 2001 at 15:09:23 Pacific
Reply:

To start out mabee experiment with the "random()" function.


// sample program to generate random numbers
#include"stdio.h"
#include"stdlib.h"

void main()
{
char ch = 0, j, sum = 0;
printf("Press 'c' to cast the dice \n 'q' to quit:\n\n");
randomize();
do
{
ch = getch();
j = random(6) + 1;
sum += j;
printf("You cast: %d\nYour total: %d\n\n", j, sum);
}
while(ch == 'c');
}


0

Response Number 2
Name: Edgar
Date: December 30, 2001 at 16:06:02 Pacific
Reply:

thx dude..... but i have some question here, you use lettle c for what in this line while(ch==c).... because that`c` hasn`t been declare as variable...


0

Response Number 3
Name: Bob
Date: December 30, 2001 at 16:20:29 Pacific
Reply:

'c' is a constant because it is enclosed in single quotes.

ch == 'c'
checks the variable "ch" with the logical operator == to see if the character constant 'c' or 0x63 has been entered.

good luck on your program.



0

Response Number 4
Name: Edgar
Date: December 30, 2001 at 16:26:11 Pacific
Reply:

thx dude!!!!!!!


0

Response Number 5
Name: Edgar
Date: December 30, 2001 at 16:45:48 Pacific
Reply:

hey bob i really appreciate your help however i need more help dude.... i`m getting crazy..... i`m using turbo c 2.0 and i`m getting 2 errors on the program, the first one is about the while line it said undefined symbol c in function main and the second one is "declaration syntax error in function main"....


0

Related Posts

See More



Response Number 6
Name: Bob
Date: December 30, 2001 at 20:10:00 Pacific
Reply:

Perhaps you need the "time.h" library for the random() function. Also "conio.h" if getch() does not function. Since you have an older version of C compiler than mine(i use 3.0) than mabee you need these. Also make sure you have single quotes around the c variabe.
while(ch == 'c');



0

Response Number 7
Name: rajhem21
Date: December 31, 2001 at 10:37:52 Pacific
Reply:

hai yez plz linux help. yez!!!!
hai, my english good. hai
yes plz.

whatis troll?

lunix is sux!!lunix is sux!!lunix is sux!!lunix is sux!!lunix is sux!!
lunix is sux!!lunix is sux!!lunlunix is sux!!lunix is sux!!ix is sux!!lunix is sux!!lunix is sux!!lunix is sux!!
lunix is sux!!lunix is sux!!lunix is sux!!
--- ack!
india 0wnz j00's ch4t roomz.


0

Response Number 8
Name: what??
Date: December 31, 2001 at 12:20:26 Pacific
Reply:

happy new year amigo!!!!!!!!!!!!



0

Response Number 9
Name: Edgar
Date: December 31, 2001 at 18:03:48 Pacific
Reply:

hey guys HAPPY NEW YEAR!!!!!!!!!!!!

hey bob do u think that the function void is stand on this version of turbo c?....
i think i`m having problem with that dude `cause i get every time DECLARATION SYNTAX ERROR IN FUNCTION MAIN......


0

Response Number 10
Name: Bob
Date: December 31, 2001 at 18:59:39 Pacific
Reply:

Ya mabee put:
int main()

at the beginning and:
return 0;

at the end, then try it.

Check your email for the program.


0

Response Number 11
Name: Edgar
Date: December 31, 2001 at 22:24:36 Pacific
Reply:

thx dude!!!!!!

hey bob can u hook me up with a link to download turbo c 3.0, i got a version of it but it doesn´t work well.....
turbo c pops a problem everytime i run it on my pc, i´m using win98 second edition

i dunno what happened



0

Response Number 12
Name: anonymous
Date: January 1, 2002 at 11:53:27 Pacific
Reply:

You can download Borland's C++ 5.5 compiler from the Borland web site here:

http://www.borland.com/bcppbuilder/freecompiler/cppc55steps.html


0

Response Number 13
Name: Bob
Date: January 3, 2002 at 10:29:18 Pacific
Reply:

Add some spice to your dice!!
Here's a neat little graphic that runs in Dos

#include
#include
#include
#include
#define BORD 0x0600
#define DOT  0x0F00
#define NORMAL 0x0700


union REGS regs;
int far *farptr;
int dot_1 = 1136;
int dot_2[] = { 972, 1300 };
int dot_3[] = { 972, 1136, 1300 };
int dot_4[] = { 972, 980, 1292, 1300 };
int dot_5[] = { 972, 980, 1136, 1292, 1300 };
int dot_6[] = { 972, 980, 1132, 1140, 1292, 1300 };


void clrs()
{
int charac;
for(charac = 0; charac < 2000; charac++)
    *(farptr + charac) = NORMAL;
regs.h.ah = 2;
regs.x.dx = 0;
int86(0x10, ®s, ®s);
}


void outline(int blink)
{
    int j, k;
    for(k = 880; k <= 1360; k += 480)
        for(j = 11; j <= 22; j++) {
            *(farptr + k + j) = BORD ^ blink | 205;
            *(farptr + k + j + 22) = BORD ^ blink | 205;
        }
    for(k = 10; k <= 23; k += 13)
        for(j = 960; j <=1280; j += 80) {
            *(farptr + k + j) = BORD ^ blink | 186;
            *(farptr + k + j + 22) = BORD ^ blink | 186;
        }
    *(farptr + 890) = BORD ^ blink | 201;
    *(farptr + 912) = BORD ^ blink | 201;
    *(farptr + 903) = BORD ^ blink | 187;
    *(farptr + 925) = BORD ^ blink | 187;
    *(farptr + 1370) = BORD ^ blink | 200;
    *(farptr + 1392) = BORD ^ blink | 200;
    *(farptr + 1383) = BORD ^ blink | 188;
    *(farptr + 1405) = BORD ^ blink | 188;
}


void plotdot(cast, face, n)
int cast, *face, n;
{
    int x = 0;
    do {
        *(farptr + *face + 22 * n) = DOT | 219;
        *(farptr + *(face++) + 1 + 22 * n) = DOT | 219;
    }
    while(x++ < cast);
}


void condns(int die, int n)
{
    switch(die) {
        case 1:
            plotdot(0, &dot_1, n); break;
        case 2:
            plotdot(1, &dot_2, n); break;
        case 3:
            plotdot(2, &dot_3, n); break;
        case 4:
            plotdot(3, &dot_4, n); break;
        case 5:
            plotdot(4, &dot_5, n); break;
        case 6:
            plotdot(5, &dot_6, n); break;
        default:
            exit(0);
    }
}


int main()
{
    int die_1, die_2, cast_1, cast_2, t;
    farptr = (int far *) 0xB8000000;
    clrs();
    randomize();
    while(1) {
        printf("Enter two numbers(1 - 6)\n");
        printf("Hit 8 to quit: ");
        scanf("%d %d", &die_1, &die_2);
        if(die_1 == 8 || die_2 == 8)
             exit(0);
        for(t = 0; t < 10; t++) {
            cast_1 = random(6) + 1;
            cast_2 = random(6) + 1;
            clrs();
            outline(0x8000);
            condns(cast_1, 0);
            condns(cast_2, 1);
            delay(200);
        }
        clrs();
        outline(0);
        condns(die_1, 0);
        condns(die_2, 1);
    }
}



0

Response Number 14
Name: Bob
Date: January 3, 2002 at 10:44:06 Pacific
Reply:

AAAAAAAAH!! This dumb HTML!

The 4 includes are:
stdio.h
stdlib.h
dos.h
time.h


and the line int 86(0x10, ®s, ®s)
the ®s is an ampersand preceding"regs"


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C help plz

C++ int statement help www.computing.net/answers/programming/c-int-statement-help/13455.html

Help explain C code www.computing.net/answers/programming/help-explain-c-code/9658.html

HELP PLZ!!! C++ .net www.computing.net/answers/programming/help-plz-c-net-/10294.html