473,503 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error "Syntax in function main"-thing

4 New Member
Seriously, me and my stupid logic can't get rid of that syntax thing... My friend once fixed it but it reappeared when I ran it at my PC

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<time.h>
  5.  
  6. void main()
  7. {
  8. srand(time(NULL));
  9. clrscr();
  10. int you, comp;
  11. randomize();comp=rand()%3+1;
  12. printf("Jank'n Poy");
  13. printf("\n[0]Scissor\n[1]Paper\n[2]Rock");
  14. printf("\nEnter Your choice:");
  15. scanf("%d",&you);
  16. if((you==0)&&(comp==1))
  17. {printf("Your Choice: Scissor");
  18. printf("\nOpponent: Paper");
  19. printf("\nYou Win!");}
  20. else if((you==1)&&(comp==1))
  21. {printf("Your Choice: Scossor");
  22. printf("\nOpponent: Scissor");
  23. printf("\n\nDraw!");}
  24. else if((you==2)&&(comp==1))
  25. {printf("Your Choice: Rock");
  26. printf("\nOpponent: Paper");
  27. printf("\n\nYou Lose!");}
  28. else if((you==0)&&(comp==0))
  29. {printf("Your Choice: Paper");
  30. printf("\nOpponent: Paper");
  31. printf("\n\nDraw!");}
  32. else if((you==1)&&(comp==0))
  33. {printf("Your Choice: Paper");
  34. printf("\nOpponent: Scissor");
  35. printf("\n\nYou Lose!");}
  36. else if((you==2)&&(comp==0))
  37. {printf("Your Choice: Rock");
  38. printf("\nOpponent: Scissor");
  39. printf("\n\nYou Win!");}
  40. else if((you==0)&&(comp==2))
  41. {printf("Your Choice: Scissor");
  42. printf("\nOpponent: Rock");
  43. printf("\n\nYou Lose!");}
  44. else if((you==1)&&(comp==2))
  45. {printf("Your Choice: Paper");
  46. printf("\nOpponent: Rock");
  47. printf("\n\nYou Win!");}
  48. else if((you==2)&&(comp==2))
  49. {printf("Your Choice: Rock");
  50. printf("\nOpponent: Rock");
  51. printf("\n\nDraw!");}
  52. else if(you>3)
  53. {printf("Invalid Input!");}
  54.  
  55. getch();
  56. }
  57.  
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<time.h>
  5. void main()
  6. {
  7. clrscr();
  8. int a, b, c, d, e,result;
  9. printf("Color Game");
  10. printf("\n[1] Yellow \n[2] Blue \n[3] Viloet \n[4] Red \n[5] Green \n[6] Orange");
  11. printf("\n\nBet:");
  12. scanf("%d",&a);
  13. printf("Your Color:");
  14. scanf("%d",b);
  15. c=1+random(6);
  16. d=1+random(6);
  17. e=1+random(6);
  18. printf("\nColors:\t%d\t\t%d\t\t%d",c,d,e);
  19. if((b==c)&&(b==d)&&(b==e))
  20. {result=a*5;
  21. printf("\n\n\t\tPrize:%d",result);}
  22. else if(!(b==c)&&(b==d)&&(b==e))
  23. {result=a*3;
  24. printf("\n\n\t\tPrize:%d",result);}
  25. else if((b==c)&&!(b==d)&&(b==e))
  26. {result=a*3;
  27. printf("\n\n\t\tPrize:%d",result);}
  28. else if((b==c)&&(b==d)&&!(b==e))
  29. {result=a*3;
  30. printf("\n\n\t\tPrize:%d",result);}
  31. else if(!(b==c)&&!(b==d)&&(b==e))
  32. {result=a*2;
  33. printf("\n\n\t\tPrize:%d",result);}
  34. else if((b==c)&&!(b==d)&&!(b==e))
  35. {result=a*2;
  36. printf("\n\n\t\tPrize:%d",result);}
  37. else if(!(b==c)&&(b==d)&&!(b==e))
  38. {result=a*2;
  39. printf("\n\n\t\tPrize:%d",result);}
  40. else if(!(b==c)&&!(b==d)&&!(b==e))
  41. {printf("\n\n\t\tSorry, You Lose!");}
  42. getch();
  43. }
  44.  
Aug 12 '12 #1
3 1774
weaknessforcats
9,208 Recognized Expert Moderator Expert
It's probably right here:

Expand|Select|Wrap|Line Numbers
  1. srand(time(NULL));
The time function returns a time_t but the srand function needs an unsigned int as an argument.

I expect after you cnvert a time_t to an unsigned int, your code will compile.
Aug 12 '12 #2
armelle22
4 New Member
Uhmn.. so, what statement should I add or remove to make that error disappear?
Aug 13 '12 #3
divideby0
131 New Member
Expand|Select|Wrap|Line Numbers
  1. srand((unsigned)time(NULL));

Expand|Select|Wrap|Line Numbers
  1. printf("Your Color:");
  2. scanf("%d",b); <-- &b
  3.  
you'll want to fix this one

Expand|Select|Wrap|Line Numbers
  1. #include<conio.h> non-standard header
  2.  
  3. randomize()  non-standard function, I think
  4. clrscr() non-standard function
  5.  
the code bits above may cause problems depending on the compiler you're using.

post the compiler warnings / errors
Aug 13 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3747
by: Sylwia | last post by:
Hi! I need your help... I have the following problem. I've implemented the python Windows Service which behaves like a log supervisor. If the space used by log files is bigger than a given...
1
1584
by: Larry Bates | last post by:
It doesn't happen often, but once in a while I will introduce a syntax error into a Python program I'm working on (in IDLE) and doing File-Check responds with the expected "Failed to check, syntax...
4
5140
by: James | last post by:
Please help me with this sql: SELECT z005aNORTHEAST_3days_Formula.Region, z005aNORTHEAST_3days_Formula.DiffofClaimsAssignment FROM (SELECT .Region, (.)-( .) AS DiffofClaimsAssignment FROM...
2
34491
by: nick | last post by:
the following is my programming code and compile message why the warning message arise, have i done somethings wrong? #include<stdio.h> typedef struct card{ int abc; }card;
7
8489
by: Eric | last post by:
Hi For this code, int getopt (int argc, char *const argv, const char *opts) what does the "char *const argv" mean? Does it equal to "char **const argv"? Or "char *const *argv"? Which is the...
2
1607
by: mirandacascade | last post by:
I am prompted to make these inquiries after seeing the following link to ctypes: http://docs.python.org/lib/module-ctypes.html in which ctypes is described as a foreign function library. ...
1
4268
by: BobPaul | last post by:
I'm following code out of a howto book and this is really bugging me. This header file was created by VStudio 6.0 when I did a "Right Click: Add Member Function" CLine is a class I wrote (per the...
3
1467
by: Aries Sun | last post by:
I am reading the book "Effective C++" Item 25 mentioned the following code: // a first cut at a class yielding NULL pointer objects class NullClass { public: template<class T ...
6
6474
by: blackdogharry | last post by:
Hi, I am a novice VBA user. My access version is 2007 on Windows XP PC. I need to create a query that will take pre-existing text values of the B_status field (such as "Received_Emailed",...
3
13073
by: lingjun | last post by:
Hi, I am taking my first programing course in college... and I am completely lost on this assignment. I am not sure what is wrong with my current code. Any help will be appreciate it... thanks! ...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.