<分区>
基本上,我试图增加 port
的 int 值。这应该很容易,但我有点卡住了。
它编译很好,但是当我运行它时出现了这个错误: 访问冲突写入位置 0x001f5834
#include "stdafx.h"
#include "iostream"
using namespace std;
#define TESTING "5002"
int main()
{
char* port = TESTING;
int portint;
sscanf ( port, "%d", &portint );
portint++;
cout << portint << endl; // it works fine up to here, it prints 5003
sprintf ( port, "%d", portint);
return 0;
}