943,880 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 448
  • C++ RSS
Nov 30th, 2008
0

need help with group compiling c/c++ programs

Expand Post »
I have a c++ program that performs a functionality.
generate.h
C++ Syntax (Toggle Plain Text)
  1. struct code
  2. {
  3. bool out;
  4. bool *reg;
  5. };
  6.  
  7. class Cyclic
  8. {
  9. private:
  10.  
  11. struct code *cy;
  12. int rgsize;
  13. bool *gen;
  14. int gensize;
  15. unsigned short cycodes[256];
  16.  
  17. public:
  18.  
  19. Cyclic(int a, int b,bool c[]);
  20. void leftShift();
  21. bool* cyclicCode(bool mssg[],int msize);
  22. void printReg();
  23. bool* cboolConverter(char a);
  24. bool* uboolConverter(unsigned short a);
  25. unsigned short ushortConverter(bool ut[]);
  26. void tableGenerator();
  27. unsigned short tableRead(char a);
  28. int crcCheck(unsigned short a)
  29. };

i hav to use this program in socket programming.
C++ Syntax (Toggle Plain Text)
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <errno.h>
  5. #include <string.h>
  6. #include <netdb.h>
  7. #include <sys/types.h>
  8. #include <netinet/in.h>
  9. #include <sys/socket.h>
  10. #define PORT 3490 // the port client will be connecting to
  11.  
  12. #include "generate.h"
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16. int sockfd, numbytes,len,i;
  17. struct sockaddr_in srvr_addr; // server address information
  18. FILE *fp=fopen("1.mfcc","r");
  19. char becc;
  20. unsigned short aecc;
  21. bool g[9]={1,0,0,0,0,0,1,1,1};// g(x)=x^8 + x^2 + x + 1
  22. Cyclic cd(8,9,g);
  23. cd.tableGenerator();
  24. if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
  25. perror("socket");
  26. exit(1);
  27. }
  28.  
  29. srvr_addr.sin_family = AF_INET; // host byte order
  30. srvr_addr.sin_port = htons(PORT); // short, network byte order
  31. srvr_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
  32. memset(&(srvr_addr.sin_zero),'\0', 8); // zero the rest of the struct
  33.  
  34. if (connect(sockfd, (struct sockaddr *)&srvr_addr,
  35. sizeof(struct sockaddr)) == -1) {
  36. perror("connect");
  37. exit(1);
  38. }
  39. while(!feof(fp)){
  40. //bzero(buf,sizeof(buf));
  41. fread(becc,sizeof(char),1,fp);
  42. aecc=cd.tableRead(becc);
  43. send(sockfd,aecc,2);
  44. }
  45. printf("File sent.\n");
  46. close(sockfd);
  47. fclose(fp);
  48. return 0;
  49. }

which obviously wont get compiled bcos my socket program is a c program....how do i merge these two
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
AutoC is offline Offline
74 posts
since Sep 2008
Nov 30th, 2008
0

Re: need help with group compiling c/c++ programs

>> how do i merge these two

1) Write a c++ program instead of C program.

or

2) Write a c++ stub program that has functions callable from C program and link the two object codes together.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,952 posts
since Aug 2005
Nov 30th, 2008
0

Re: need help with group compiling c/c++ programs

Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008

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: dev-c++ Premature Closing
Next Thread in C++ Forum Timeline: Does it need a copy constructor and an operator= for a class which have array member





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


Follow us on Twitter


© 2011 DaniWeb® LLC