Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted.

char cc[1024];   //此处如果索引值设置小了,就会出问题。比如:char cc[1];是由于建立的数组下标溢出造成的

 // vc2_2_4UDPserver_Txwtech.cpp : 定义控制台应用程序的入口点。
//
#include "StdAfx.h"
#include <WinSock2.h>
#include<stdio.h>
#include<Windows.h>
#pragma comment(lib,"WS2_32.lib")
int main()
{
WSADATA data;
WORD w=MAKEWORD(,);
char sztext[]="欢迎您\r\n";
::WSAStartup(w,&data);
SOCKET s;
s=::socket(AF_INET, SOCK_DGRAM,);
sockaddr_in addr,addr2;
int n=sizeof(addr2);
char buff[]={};
addr.sin_family=AF_INET;
addr.sin_port=htons();
addr.sin_addr.S_un.S_addr=INADDR_ANY;
::bind(s,(sockaddr*)&addr,sizeof(addr));
printf("UDP服务器已经启动\r\n");
while()
{
char cc[]; //此处如果索引值设置小了,就会出问题。比如:char cc[1];是由于建立的数组下标溢出造成的
//c=getchar();
// c='';
printf("请输入C:");
scanf("%s",cc);
//sztext=c;
// strcpy(sztext,c);
if (strcmp(cc,"qq")==) {
printf("即将退出%s",cc);
::Sleep();
::closesocket(s);
::WSACleanup();
// strcpy(cc,"");
return ;
}
if(::recvfrom(s,buff,,,(sockaddr*)&addr2,&n)!=)
{
printf("%s已经连接上\r\n",inet_ntoa(addr2.sin_addr));
printf("%s\r\n",buff); ::sendto(s,sztext,sizeof(sztext),,(sockaddr*)&addr2,n);
// break;
} }
::closesocket(s);
::WSACleanup(); if(getchar())
{
return ;
//::sendto(s,sztext,sizeof(sztext),0,(sockaddr*)&addr2,n);
}
else
{
::Sleep();
}
}

c++. Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted.的更多相关文章

  1. VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法

    问题 : 在用VS2008写一段代码,算法都没有问题,但是调试的时候发现出了main之后就报 Stack around the variable 'xxx' was corrupted 的错误,后来发 ...

  2. Run-Time Check Failure #2 Stack around the variable ‘xxx’ was corrupted

    在改别人代码时,运行报错: Run-Time Check Failure #2 Stack around the variable 'buffer' was corrupted 这表明你对某变量的赋值 ...

  3. Run-Time Check Failure #2 - Stack around the variable 's' was corrupted. 出现了 。

    程序中存在内存越界,注意数组大小和数据大小.

  4. Run-Time Check Failure #2 - Stack around the variable 'ucPriKey' was corrupt

    Run-Time    Check    Failure    #2        一般是栈被破坏,你的代码可能有缓冲区溢出一类的问题. Run-Time Check Failure #2 - Sta ...

  5. vs中 Stack around the variable 'XXX' was corrupted.

    https://blog.csdn.net/hou09tian/article/details/75042206 把 project->配置属性->c/c++->代码生成->基 ...

  6. Stack around the variable 'szStr' was corrupted.

    错误:stack around the variable “XX” was corrupted.,中文翻译就是“在变量XX周围的堆栈已损坏”. 把 project->配置属性->c/c++ ...

  7. stack around the variable “XX” was corrupted

    晚上花了几个小时fix了这个恼人的BUG!“在变量XX周围的堆栈已损坏” 在网上找到的解释是: 把“project->配置属性->c/c++->代码生成->基本运行时检查 设置 ...

  8. vs中“Stack around the variable was corrupted”的解决方案

    把 project->配置属性->c/c++->代码生成->基本运行时检查 为 默认值 就不会报本异常.具体原因正在研究中... 如果改为其他就有exception. exce ...

  9. 运行时错误:“stack around the variable…was corrupted”

    造冰箱的大熊猫@cnblogs 2018/11/1 引发问题的代码片段如下 WORD var; scanf ( "%d", &var ); 包含上述代码的程序,编译正常,运 ...

随机推荐

  1. [PHP学习教程 - 文件]001.高速读写大数据“二进制”文件,不必申请大内存(Byte Block)

    引言:读写大“二进制”文件,不必申请很大内存(fopen.fread.fwrite.fclose)!做到开源节流,提高速度! 每天告诉自己一次,『我真的很不错』.... 加速读写大文件,在实际工作过程 ...

  2. 小工具之apk黑屏自动检测

    在打包测试的时候经常发送给测试组之后,发现已进入游戏就黑屏,这个就浪费了测试组的精力,如果要测试多款产品的话,就会因为黑屏问题做很多无用功,这是程序就需要在发给测试的时候自己先测试产品会不会黑屏.同样 ...

  3. C/C++多参数函数参数的计算顺序与压栈顺序

    一.前言 今天在看Thinking in C++这本书时,书中的一个例子引起了我的注意,具体是使用了下面这句 单看这条语句的语义会发现仅仅是使用一个简单的string的substr函数将所得子串pus ...

  4. STM32读取bq33100数据——硬件IIC

    背景:拟采用bq33100超级电容管理芯片,实现自动的超级电容组的均压任务.需监控芯片的工作情况,以及电容组的均压情况. 平台: 硬件:STM32F103C8T6 通信:SMBus(低速IIC) 目标 ...

  5. golang内置类型和内置函数

    golang内置类型和内置函数是不需要引入包直接可用的 golang内置类型: 数值类型 string int,unint float32,float64 bool array 有长度的 comple ...

  6. Java实现 LeetCode 面试题62. 圆圈中最后剩下的数字(约瑟夫环)

    面试题62. 圆圈中最后剩下的数字 0,1,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字.求出这个圆圈里剩下的最后一个数字. 例如,0.1.2.3.4这5个数字组成一个圆 ...

  7. Java实现 计蒜客 拯救行动

    拯救行动 公主被恶人抓走,被关押在牢房的某个地方.牢房用 N \times M (N, M \le 200)N×M(N,M≤200) 的矩阵来表示.矩阵中的每项可以代表道路(@).墙壁(#).和守卫( ...

  8. Java实现 LeetCode 12 整数转罗马数字

    12. 整数转罗马数字 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 ...

  9. Java实现LeetCode #986 - Interval List Intersections

    class Solution { public: vector<Interval> intervalIntersection(vector<Interval>& A, ...

  10. Java实现Catenyms(并查集+dfs+欧拉回路)

    Description A catenym is a pair of words separated by a period such that the last letter of the firs ...