I am writing a program implementing go-back n arq bidirectional using windows server. but i got conflicted in the lines I posted down here. I declared size as int and it is global variable but seems not to be working this way perhaps. any ideas
#include <stdlib.h>
#include <time.h>
#include <WinSock2.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <io.h>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
#define SERVER_PORT 12340
#define SERVER_IP "127.0.0.1"
const int BUFFER_LENGTH = 1026;
const int SEND_WIND_SIZE = 15;
const int SEQ_SIZE = 20;
BOOL ack[SEQ_SIZE];
int curSeq;
int curAck;
int totalSeq;
int totalPacket;
int size;
int flag = 0;
int checksum;
int main(int argc, char* argv[]) {
/*other part here not affected*/
>but from down there it says size is ambigus
FILE* file;
fopen_s(&file, "./test.txt", "rb");
size = _filelength(_fileno(file));
printf("Open the files%d \n", size);
fclose(file);
//char data[1024 * 113];
char* data = new char[size];
ZeroMemory(data, sizeof(data));
icin.read(data, size);
icin.close();
}
- I declare it previously as global variable
- Here is the error message:
Severity Code Description Project File Line Suppression State Error
(active) E0266 "size" is ambiguous
I also have removed it from global declaration and yet still highlighting an error