Okay, I know there is a prior article about this, but I used { } with my if statements, and it's still not working... is it because I have multiple if statements consecutively after another?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int i, n,t, s[51],p=1,a,b,c;
int main() {
srand(1);
for(i=0;i<=51;i++) {
if (p>13) {
p=1; }
s[i] = p;
p++;
}
printf("\n");
for(i=0;i<52;i++) {
a = n;
n = rand()%52;
if (s[n]<0 || s[a]<0) {
--i; }
else {
if ((s[n]=1)) {
b=11;
printf("A + "); }
else if (s[n] == 11); {
b=s[n];
printf("J + "); }
else if (s[n] == 12); {
b=s[n];
printf("Q + "); }
else if (s[n] == 13); {
b=s[n];
printf("K + "); }
else {
b=s[n];
printf("%i + ",b); }
if ((s[a]=1)) {
c=11;
printf("A = "); }
else if (s[a] == 11); {
c=s[a];
printf("J = "); }
else if (s[a] == 12); {
c=s[a];
printf("Q = "); }
else if (s[a] == 13); {
c=s[a];
printf("K = "); }
else {
c=s[a];
printf("%i = ",c); }
if((b+c=21)){
printf("%i blackjack!\n",b+c);
s[n]=-1;
s[a]=-1;}
else{
printf("%i\n",b+c);
s[n]=-1;
s[a]=-1;
}
}
}
return 0; }
these are the errors I'm coming up with:
p2.c:29: error: 'else' without a previous 'if'
p2.c:32: error: 'else' without a previous 'if'
p2.c:35: error: 'else' without a previous 'if'
p2.c:44: error: 'else' without a previous 'if'
p2.c:47: error: 'else' without a previous 'if'
p2.c:50: error: 'else' without a previous 'if'
p2.c:53: error: lvalue required as left operand of assignment