主题:初学C#遇到问题了
我是一个刚刚开始学编程的人,可刚开始就被难倒了,我用的是Microsoft Visual C# 2005 Express Edition,直接新建一个window程序,C语言不是直接提供界面么!我双击了那个界面,发现里面已经有代码了,大概是界面的代码吧。问题开始了,我在本就存在的代码下继续打下面这段代码:
#include<stdio.h>
{
int main(void)
printf("How many dogs do you have?\n");
scanf("%d",&dogs);
printf ("So you have %d dog(s) !\n",dogs)
return 0;
}
按照书上说,这段代码是正常的,可运行时就出错,而且,如果输入的是函数,Microsoft Visual C# 2005 Express Edition会自动弹个选择框出来的,可我打int这个时没有弹出,而且,软件好像也不接受printf、#include这些内容。
错误提示:
Error 1 Preprocessor directive expected C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 24 2 WindowsApplication1
Error 2 Single-line comment or end-of-line expected C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 24 9 WindowsApplication1
Error 3 A namespace does not directly contain members such as fields or methods C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 25 1 WindowsApplication1
Error 4 Type or namespace definition, or end-of-file expected C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 31 1 WindowsApplication1
我该怎么做
#include<stdio.h>
{
int main(void)
printf("How many dogs do you have?\n");
scanf("%d",&dogs);
printf ("So you have %d dog(s) !\n",dogs)
return 0;
}
按照书上说,这段代码是正常的,可运行时就出错,而且,如果输入的是函数,Microsoft Visual C# 2005 Express Edition会自动弹个选择框出来的,可我打int这个时没有弹出,而且,软件好像也不接受printf、#include这些内容。
错误提示:
Error 1 Preprocessor directive expected C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 24 2 WindowsApplication1
Error 2 Single-line comment or end-of-line expected C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 24 9 WindowsApplication1
Error 3 A namespace does not directly contain members such as fields or methods C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 25 1 WindowsApplication1
Error 4 Type or namespace definition, or end-of-file expected C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.cs 31 1 WindowsApplication1
我该怎么做