[英]How to fix Illegal use of floating point error in C++
I am getting type mismatch and illegal use of floating point error in this C++ program in Turbo C++. 我在Turbo C ++中的此C ++程序中遇到类型不匹配和非法使用浮点错误的情况。 Here I am trying to illustrate GO BACK n ARQ protocol but I am not getting why ws variable is involved with error.
在这里,我试图说明GO BACK n ARQ协议,但我不明白为什么ws变量包含错误。
#include<iostream.h>
#include<conio.h>
#include<math.h>
int ws,sf,ef,m; //Type mismatch error
int i,ack[50];
char ch;
void send(int sf){
for(i=sf;i<=(ws-1);i++){
cout<<"\n\n\nFrame "<<i<<" got acknowledged?(y/n)";
cin>>ch;
if(ch=='y'){
ack[i]=1;
cout<<"Acknowledgement recieved for frame "<<i;
}
if(ch=='n'){
cout<<"Acknowledgement not recieved for frame "<<i;
ack[i]=0;
}
}
}
int check()
{
for(int k=0;k<=(ws-1);k++)
{
if(ack[k]==0)
return 1;
}
return 0;
}
int main()
{
int m;
cout<<"Enter the size of data";
cin>>m;
ws=pow(2,m)-1; //illegal floating point error
sf=0;
ef=sf+ws-1;
send(0);
while(check())
{
for(i=0;i<ws-1;i++)
{
if(ack[i]==0)
{
send(i);
}
}
}
cout<<"Packet recieved";
getch();
return 0;
}
I want to use ws as a global variable that is used in other functions. 我想将ws用作其他函数中使用的全局变量。
您有一个名称冲突:wsstream已在iostream.h中定义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.