| | |
need help with group compiling c/c++ programs
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 62
Reputation:
Solved Threads: 0
I have a c++ program that performs a functionality.
generate.h
i hav to use this program in socket programming.
which obviously wont get compiled bcos my socket program is a c program....how do i merge these two
generate.h
C++ Syntax (Toggle Plain Text)
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.
C++ Syntax (Toggle Plain Text)
#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.
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.
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: dev-c++ Premature Closing
- Next Thread: Does it need a copy constructor and an operator= for a class which have array member
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






