When I learn languages I normally make up my own examples to help me learn, and as its my first day with C the one I am working on is quite ambitious, but i'm determined to complete it.
However all the different blocks of code are confusing my compiler (gcc). It will be easier for me to explain my problem and what I want to do by showing you code, so here goes:
Code:
#include <stdio.h>
int main();
{
int points;
char decision;
char deal;
char play;
printf ( "Welcome to Ben's blackjack game!\n" );
printf ( "Would you like to play (y or n)\n" );
scanf ( "% ", &play );
if ( play == "y" ) {
printf ( "Press d to deal, or press h for help\n" );
scanf ( "% ", &deal );
if ( deal == "h" ) {
printf ( "In blackjack, the player aims to get 21 points each deal. They do this by getting cards of different values\n but if the player gets over 21 then they are bust, which means they get 0\n" );
}
else {
printf ( "Invalid Command\n" );
}
}
else if ( play == n ) {
printf ( "Ok then, bye!\n" );
}
else {
printf ( "Invalid Command\n" );
}
}
Code:
#include <stdio.h>
int main();
{
char deal;
char play;
printf ( "Welcome to Ben's blackjack game!\n" );
printf ( "Would you like to play (y or n)\n" );
scanf ( "% ", &play );
if ( play == "y" ) {
/* a command to run ./game would appear here, if there is such a thing */
}
else if ( play == n ) {
printf ( "Ok then, bye!\n" );
}
else {
printf ( "Invalid Command\n" );
}
}
Thanks,
Ben


/me begs for mercy.