944,070 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1212
  • C RSS
Apr 19th, 2007
0

help with some error codes please.

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fatboysudsy is offline Offline
11 posts
since Mar 2007
Apr 19th, 2007
0

Re: help with some error codes please.

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,957 posts
since Aug 2005
Apr 19th, 2007
0

Re: help with some error codes please.

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 ?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fatboysudsy is offline Offline
11 posts
since Mar 2007
Apr 19th, 2007
0

Re: help with some error codes please.

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.
Moderator
Reputation Points: 3281
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: string manipulation
Next Thread in C Forum Timeline: strcmp doesn't work... =(





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC