need help with group compiling c/c++ programs

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 62
Reputation: AutoC is an unknown quantity at this point 
Solved Threads: 0
AutoC AutoC is offline Offline
Junior Poster in Training

need help with group compiling c/c++ programs

 
0
  #1
Nov 30th, 2008
I have a c++ program that performs a functionality.
generate.h
  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.
  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,343
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: 1458
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #2
Nov 30th, 2008
>> 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.
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: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

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

 
0
  #3
Nov 30th, 2008
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC