help with some error codes please.

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2007
Posts: 11
Reputation: fatboysudsy is an unknown quantity at this point 
Solved Threads: 0
fatboysudsy fatboysudsy is offline Offline
Newbie Poster

help with some error codes please.

 
0
  #1
Apr 19th, 2007
Hi all,

Am fairly new to the programming world, but am kind of struggling along. I have written a piece of code for a client program with has given me some errors that i just can't see when compiling. The errors listed are :

  1. client.c: In function `main':
  2. client.c:118: error: syntax error before '-' token
  3. client.c: At top level:
  4. client.c:132: error: conflicting types for `close_socket'
  5. sockets.c.h:40: error: previous declaration of `close_socket'
  6. client.c:133: error: parse error before '}' token
  7.  

And i have also listed the program below. I hope that someone can point out the errors in my ways. Thanks in advance for looking.

  1. ;
  2. char box[5];
  3. char ack[50];
  4. int boxlenerr;
  5. char view_data[256];
  6.  
  7. printf("client ...\n");
  8. printf("please enter host server name\n");
  9. scanf("%s",server);
  10. printf("please enter server port number\n");
  11. scanf("%d",&port); /* remember the "&" to allow scanf to store the input value */
  12.  
  13. local_socket = create_socket();
  14. printf("client: socket %d created\n", local_socket);
  15.  
  16. ok=connect_sockets(local_socket, server, port);
  17. /* socket is connected at this point */
  18.  
  19. printf("Please enter your SetTopBox Number\t");
  20. scanf("%s",box);
  21.  
  22. if (strlen(box) !=10)
  23. {
  24. printf("Incorrect box number, please try again later\n");
  25. }
  26. else
  27. {
  28. send_data(local_socket,box,strlen(box)+1);
  29. recv_data(local_socket,ack);
  30. }
  31.  
  32. printf("Please enter your Customer ID\t");
  33. scanf("%s",id);
  34.  
  35. if (strlen(id) !=4)
  36. {
  37. printf("Your ID number needs to be 4 digits long\n");
  38. }
  39. else
  40. {
  41. send_data(local_socket,id,strlen(id)+1);
  42. recv_data(local_socket,ack);
  43. }
  44.  
  45. int option;
  46. option = 0;
  47. printf("NuTV SELECTION MENU");
  48. while (option !=4)
  49. {
  50. display_menu();
  51. option = get_selection();
  52. switch (option)
  53. {
  54. case 1: get_prog_ch();
  55. break;
  56. case 2 : get_prog_cat();
  57. break;
  58. case 3 : get_prog_sub();
  59. break;
  60. }
  61. }
  62. printf(" Thanks for calling Goodbye\n\n");
  63.  
  64. if (ok < 0)
  65. {
  66. printf("failed to connect sockets\n");
  67. }
  68. else
  69. {
  70. printf("client: connection made to server, now use service\n");
  71.  
  72. len=recv_data(local_socket,data);
  73.  
  74. printf("client: %d bytes of data received\n",len);
  75.  
  76. /* now display the data received, character by character */
  77. for (i=0;i<len;i++)
  78. { printf("%c",data[i]);
  79. }
  80. printf("\n");
  81. }
  82.  
  83. void display_menu()
  84. {
  85. printf("\n");
  86. printf("Please choose an option\n");
  87. printf("1-Choose programmes by channel number\n");
  88. printf("2-Choose programmes by category\n");
  89. printf("3-Choose programmes bt ctegory & sub-categroy\n");
  90. printf("4- Exit the system\n");
  91. }
  92.  
  93. int get_selection()
  94. {
  95. int ch =0;
  96. while (ch >3 && ch <1)
  97. {printf("please enter your choice (1-3) and press return:\n");
  98. scanf("%d",&ch);
  99. }
  100. return (ch);
  101. }
  102.  
  103. void get_prog-ch()
  104. {
  105. printf(" this gets you the channels");
  106. }
  107.  
  108. void get_prog_cat()
  109. {
  110. printf(" By category");
  111. }
  112.  
  113. void get_prog_sub()
  114. {
  115. printf("By sub category");
  116. }
  117.  
  118.  
  119. }
Last edited by Ancient Dragon; Apr 19th, 2007 at 9:15 am. Reason: corrected code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,660
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1500
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: help with some error codes please.

 
0
  #2
Apr 19th, 2007
The problem is mis-matched braces '{' and '}'. delete line 119.

what is the semicolon doing on line 1?
Last edited by Ancient Dragon; Apr 19th, 2007 at 9:18 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 11
Reputation: fatboysudsy is an unknown quantity at this point 
Solved Threads: 0
fatboysudsy fatboysudsy is offline Offline
Newbie Poster

Re: help with some error codes please.

 
0
  #3
Apr 19th, 2007
hi,

Thanks have done that, think that the ; is a typo error. Now when i compile i get :


gcc -w stream_sockets.o client.c -o client
display_menu
get_selection
get_prog_ch
get_prog_cat
get_prog_sub
collect2: ld returned 1 exit status
*** Exit 1
Stop.

what is going on here ?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,131
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: help with some error codes please.

 
0
  #4
Apr 19th, 2007
I would guess you call the ld system command from somewhere in your program and it returned with an error. But it's only a guess since there's no code posted to verify it.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum


Views: 962 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC