I just need a head start with this C program that I need to write. Any help woul
ID: 3638975 • Letter: I
Question
I just need a head start with this C program that I need to write. Any help would be appreciated.Creating atleast one function for each layer. These functions are going to be called layerA, layerB, layerC and layerD. If needed, you may write additional functions for any layer to implement specific features, as needed. A detailed description of the behavior of these layers is given below.
Write two main functions in main: transmit and receive. The transmit function will first do:The transmit function first calls layerD. LayerD opens a file named sendfile.txt and reads all the data stored therein, character by character in a data buffer (array). You may assume that the file has at most 2 KB (i.e. 2048 bytes) of data. The contents of the data buffer look like this: Data read from sendfile.txt
Explanation / Answer
It's kind of hard to tell what to do exactly from your description. You can start by writing the transmit function. In C, the file IO functions you're going to want to use are:
fopen()
fgetc()
fclose()
Just declare an array of 2048 characters and then fill with whatever is returned by fgetc(). Look here for an example of basic C IO:
http://www.cplusplus.com/reference/clibrary/cstdio/fgetc/