0
 skittles.c:6:1: error: expected identifier or '('
 {
 ^

this is my error and this is my uncleaned up code

#include <stdio.h>
#include <cs50.h>

 int main(void);
{
int tries = (0);
int total = rand() % 1024;
{
printf("guess a number between 1 and 1023\n");
int num = GetInt();
loop:
}
while (num < total)
{
printf("%d is to low\n", num);
num = GetInt();
tries++;
goto loop;
}
while (num > total)
{
printf("%d is to high\n", num);
num = GetInt();
tries++;
goto loop;
}
while (num == total)
{
printf("%d is perfect\n", num);
printf("it took you %d tries", tries);
}
}
0

Drop the () around the assignment at line 6. On the side you should look into indenting your code if you haven't already, as well as add whitespace. If I remember correctly the goto statement is frowned upon in the C community for various reasons, if using it wasn't a requirement for the task you should consider removing it so that you so not get in the habit of using it.

Oh and by the way. Assuming you watch the lectures (or APCS50 lectures) you can download the code shown in lecture at edx's website and also I think at https://study.cs50.net, if there are different lectures at APCS50 I am not sure. Either way you should find a book or website to help you on your way because the questions you have asked are very basic. For the website I recommend https://learnxinyminutes.com

6
  • thank you and it is indented why is goto frowned opon just wondering – rudawn Sep 25 '16 at 21:32
  • thank you and same lectures – rudawn Sep 25 '16 at 21:51
  • I'm sorry I did not see it before. It is the semi-colon in int main(void); that shouldn't be there. The parentheses are unnecessary but unlikely to cause any harm. – kluvin Sep 25 '16 at 21:54
  • thank you that was killing me – rudawn Sep 26 '16 at 17:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .