473,568 Members | 3,014 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 1777
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
3749
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 upper limit, then it starts to delete log files until the space is less than a given
1
1590
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 error - invalid syntax". The problem is where the cursor stops is perfectly legal syntax. I then begin going through the laborious job of...
4
5147
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 (SELECT .Region, ., ., .
2
34509
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
8508
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 const? Thanks
2
1610
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. What is the definition of "foreign function library"? Is the concept different from a "package"? Is the concept different from a "module"?
1
4275
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 book's instructions) and Line.h in included in Day10Doc.cpp Here is the contents of Day10Doc.h #if...
3
1471
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 // generates operator T*() const { return 0; } // operator T* for }; // all types T; each // function...
6
6480
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", "Processed" etc.) and return the numeric value depending on the value of the B_status value. So I would get 2 in the new field if the value of...
3
13087
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! I keep on getting the follow error messages when I try to compile it. test.c:3: error: syntax error before numeric constant test.c: In function...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.