RSS Forums RSS

need help with group compiling c/c++ programs

Please support our C++ advertiser: Programming Forums
Reply
Posts: 54
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

  #1  
Nov 30th, 2008
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
AddThis Social Bookmark Button
Reply With Quote  
Posts: 13,866
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: 1231
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

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

  #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.
Reply With Quote  
Posts: 2,000
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: 331
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

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

  #3  
Nov 30th, 2008
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 233 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:05 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC