VC运行错误看不懂

勇敢的搬砖人 2009-07-18 08:44:10
在下面网址
http://topic.csdn.net/u/20090322/01/3AA46184-E9BE-45B9-9DA9-3C6B8829B04A.html
得到这么一段代码用VC++6.0运行,出现下面的错误,可是看不懂,望大虾指点!
using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;

class Test
{
// 获取网页的HTML内容
static string GetPage(string url)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
try
{
using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
{
using (StreamReader sr = new StreamReader(res.GetResponseStream()))
{
return sr.ReadToEnd();
}
}
}
catch (System.Exception e)
{
return e.Message;
}
finally
{
req.Abort();
}
}

// 通过外部网站得到本机的外部IP
static string GetOuterIP()
{
string patt = @"IP: \[(?<IP>[0-9\.]*)\]";
string url = "http://www.skyiv.com/info";
return Regex.Match(GetPage(url), patt).Groups["IP"].Value;
}

static void Main()
{
Console.WriteLine("Inner IP:");
foreach (IPAddress ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
{
Console.WriteLine(ip);
}
Console.WriteLine();
Console.WriteLine("Outer IP:");
Console.WriteLine(GetOuterIP());
}
}


--------------------Configuration: get IP - Win32 Debug--------------------
Compiling...
get IP .c
c:\documents and settings\administrator\桌面\get ip .c(1) : error C2061: syntax error : identifier 'System'
c:\documents and settings\administrator\桌面\get ip .c(1) : error C2059: syntax error : ';'
c:\documents and settings\administrator\桌面\get ip .c(2) : error C2061: syntax error : identifier 'System'
c:\documents and settings\administrator\桌面\get ip .c(2) : error C2059: syntax error : ';'
c:\documents and settings\administrator\桌面\get ip .c(2) : error C2059: syntax error : '.'
c:\documents and settings\administrator\桌面\get ip .c(3) : error C2061: syntax error : identifier 'System'
c:\documents and settings\administrator\桌面\get ip .c(3) : error C2059: syntax error : ';'
c:\documents and settings\administrator\桌面\get ip .c(3) : error C2059: syntax error : '.'
c:\documents and settings\administrator\桌面\get ip .c(4) : error C2061: syntax error : identifier 'System'
c:\documents and settings\administrator\桌面\get ip .c(4) : error C2059: syntax error : ';'
c:\documents and settings\administrator\桌面\get ip .c(4) : error C2059: syntax error : '.'
c:\documents and settings\administrator\桌面\get ip .c(6) : error C2061: syntax error : identifier 'Test'
c:\documents and settings\administrator\桌面\get ip .c(6) : error C2059: syntax error : ';'
c:\documents and settings\administrator\桌面\get ip .c(7) : error C2449: found '{' at file scope (missing function header?)
c:\documents and settings\administrator\桌面\get ip .c(35) : error C2018: unknown character '0x40'
c:\documents and settings\administrator\桌面\get ip .c(35) : warning C4129: '[' : unrecognized character escape sequence
c:\documents and settings\administrator\桌面\get ip .c(35) : warning C4129: '.' : unrecognized character escape sequence
c:\documents and settings\administrator\桌面\get ip .c(35) : warning C4129: ']' : unrecognized character escape sequence
c:\documents and settings\administrator\桌面\get ip .c(51) : error C2059: syntax error : '}'
执行 cl.exe 时出错.

get IP .obj - 1 error(s), 0 warning(s)
...全文
57 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qqiuzaihui 2009-07-19
  • 打赏
  • 举报
回复
C# code 在 VC++ 6.0 中运行? 有没有搞错? 楼主安装个VS2005吧。
tommir3 2009-07-18
  • 打赏
  • 举报
回复
C++啥时有Class了?
C++我懂的不多,我记得C++没有类吧?
V68V6 2009-07-18
  • 打赏
  • 举报
回复
先弄清楚是啥程序再弄清楚用啥打开
都整明白了再上来问啥问题
  • 打赏
  • 举报
回复
你贴的根本不是 vc++ 6.0 程序。
li45214521 2009-07-18
  • 打赏
  • 举报
回复
果然是天外来宾

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧