I have a c++ program that performs a functionality.
generate.h

struct code
{
        bool out;
        bool *reg;
};

class Cyclic
{
        private:

        struct code *cy;
        int rgsize;
        bool *gen;
        int gensize;
        unsigned short cycodes[256];

        public:

        Cyclic(int a, int b,bool c[]);
        void leftShift();
        bool* cyclicCode(bool mssg[],int msize);
        void printReg();
        bool* cboolConverter(char a);
        bool* uboolConverter(unsigned short a);
        unsigned short ushortConverter(bool ut[]);
        void tableGenerator();
        unsigned short tableRead(char a);
        int crcCheck(unsigned short a)
};

i hav to use this program in socket programming.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#define PORT 3490        // the port client will be connecting to

#include "generate.h"

int main(int argc, char *argv[])
{
    int sockfd, numbytes,len,i;
    struct sockaddr_in srvr_addr; // server address information
    FILE *fp=fopen("1.mfcc","r");
    char becc;
    unsigned short aecc;
    bool g[9]={1,0,0,0,0,0,1,1,1};// g(x)=x^8 + x^2 + x + 1 
    Cyclic cd(8,9,g);
    cd.tableGenerator();
    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    perror("socket");
    exit(1);
    }

    srvr_addr.sin_family = AF_INET;      // host byte order
    srvr_addr.sin_port = htons(PORT); // short, network byte order
    srvr_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    memset(&(srvr_addr.sin_zero),'\0', 8); // zero the rest of the struct

    if (connect(sockfd, (struct sockaddr *)&srvr_addr,
    sizeof(struct sockaddr)) == -1) {
    perror("connect");
    exit(1);
    }
    while(!feof(fp)){
                //bzero(buf,sizeof(buf));
                fread(becc,sizeof(char),1,fp);
                aecc=cd.tableRead(becc);
                send(sockfd,aecc,2);
                }
   printf("File sent.\n");
 close(sockfd);
  fclose(fp);
  return 0;
}

which obviously wont get compiled bcos my socket program is a c program....how do i merge these two

>> 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.