Sign in to follow this  

4 layer reference model for communication error

Recommended Posts

I'm trying to simulate a simple 4 layer reference model for communication between two hosts. However, I seem to be getting a simple error, which I can't figure out. The Part of my code is: int* layer4(int* buf,int* bufsize ,int flag) { if(flag == 1) //Transmit { //Read data from file into an array FILE *fr; int rr; fr = fopen( "sendfile.txt", "r" ); fseek(fr,0,SEEK_END); int filesize = ftell(fr); rewind(fr); buf = new int[fr]; int i=0; while((rr = getc(fr)) != EOF) { buf[i] = rr - 48; i = i+1; } (*bufsize) = filesize; fclose(fr); return buf; } else //Receive { //Store data in file FILE *fw; fw = fopen("receivefile.txt","w"); char* x; x = new char; for(int i=0; i<(*bufsize); i++) { itoa(buf[i],x,2); fputs(x,fw); } fclose(fw); } } And the following error I'm getting refers to buf = new int[fr]; In function `int* layer4(int*, int*, int)': expression in new-declarator must have integral or enumeration type

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this