Java编译能通过,但是运行的时候提示有错误

Java编译能通过,但是运行的时候提示有错误。

提示出现这样的错误:

 

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.idea.ok.Person.main(Person.java:32)
Caused by: java.lang.NullPointerException
    at org.idea.ok.Gender1.<init>(Gender1.java:28)
    at org.idea.ok.Gender1.<clinit>(Gender1.java:17)
    ... 1 more

 原程序如下:

package org.idea.ok;

/*
 *枚举类
 *既可以通过public访问权限的静态常量来访问实例;
 *也可以通过Gender1类的getInstance静态方法来访问实例变量。 
 */
 
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.Map;
import java.util.HashMap;
 
public class Gender1 implements Serializable {
    public static final Gender1 FEMALE = new Gender1(new Character('F'), "FEMALE");
    public static final Gender1 MALE = new Gender1(new Character('M'), "MALE");
    private final Character sex;
    private final transient String description;
    private static Map<Character, Gender1> instancesBySex = 
        new HashMap<Character, Gender1>();

    
    private Gender1(Character sex, String description) {
        this.sex = sex;
        this.description = description;
        instancesBySex.put(sex, this);
    }
    
    public Character getSex() {
        return sex;
    }
    
    public String getDescription() {
        return description;
    }
    
    public static Collection getAllValues() {
        return Collections.unmodifiableCollection(instancesBySex.values());
    }
    
    public static Gender1 getInstance(Character sex) {
        
        /*按照参数指定的性别缩写查找Gender1实例*/
        Gender1 result = (Gender1)instancesBySex.get(sex);
        if (result == null) {
            throw new NoSuchElementException(sex.toString());
        }
        return result;
    }
    
    public String toString() {
        return description;
    }
    
    private Object readResolve() {
        
        /*保证反序列化时直接返回Gender1类包含的静态实例*/
        return getInstance(sex);
    }
}

 

package org.idea.ok;

/*
 */
 
public class Person {
    private String name;
    private Gender1 gender;
    
    public Person(String name, Gender1 gender) {
        this.name = name;
        this.gender = gender;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public Gender1 getGender() {
        return gender;
    }
    
    public void setGender(Gender1 gender) {
        this.gender = gender;
    }
    
    public static void main(String[] args) {
        Person mary = new Person("Mary", Gender1.FEMALE);
        System.out.println("name = " + mary.getName() + "\t" + "gender = " + mary.getGender());
    }
}

 程序异常提示是:初始化的时候错误;但是造成这种异常的根源是Gender1中的代码的问题。这个我还真是找不出来了,麻烦谁能找出来的,小弟不胜感谢。

1个回答

private static Map instancesBySex =

new HashMap();

放到Gender1的开头就可以了,

是加载顺序的问题,当运行到
Person mary = new Person("Mary", Gender1.FEMALE);

这行时,系统加载Gender1类,当加载到
public static final Gender1 FEMALE = new Gender1(new Character('F'), "FEMALE");
这行时,由于还没有初始化instancesBySex ,此时instancesBySex 为null,而上面用到了instancesBySex 的put方法,出现空指针。

使用调试模式,一步一步执行,查看对象的属性就可以发现问题所在了。

自认为instancesBySex 没有必要存在,
public static Collection getAllValues() {

return Collections.unmodifiableCollection(instancesBySex.values());

}

public static Gender1 getInstance(Character sex) {   

    /*按照参数指定的性别缩写查找Gender1实例*/   
    Gender1 result = (Gender1)instancesBySex.get(sex);   
    if (result == null) {   
        throw new NoSuchElementException(sex.toString());   
    }   
    return result;   
}   

可修改为
public static Gender1[] getAllValues() {
return new Gender1[]{Gender1.FEMALE,Gender1.MALE};
}
public static Gender1 getInstance(Character sex) {

    if(set.equals(new Character("F")) {
         return Gender1.FEMALE;
    } else {
         return Gender1.MALE;
    }
} 
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
c#winform 运行没错,但是编译的时候提示错误
我在解决方案中写了一个DataBase的类库,命名空间就是DataBase,rnrn在使用后,F6编译后提示错误,DataBase里的的类名都不识别(已经引用了命名空间),而且是不确定的,有时候是不会报错的。rnrn但是F5执行的时候没有报错,也没警告,能成功运行。rnrn虽然不影响程序的运行,但是看着不爽,而且也担心是不是有什么潜在的问题才会有这种现象。rnrn各位高手不知道碰没碰到过这种问题。rnrn我用的是vs2010旗舰版rn
编译的时候提示错误
我用的9.0编的程序rn由于老是封装不成功rn所以转到6.0下编译rn提示菜单出错rnGENERATOR: 菜单 ZHUCAIDAN 无效 LINE NUMBER: 692rn请高手告知一下这个错误什么意思啊?rn
编译的时候提示错误。
vista sp2 wdk7600 vc++2008sp1rn编译SSDTHOOK 的时候 提示:rnrnProject : error PRJ0019: 某个工具从以下位置返回了错误代码: "正在执行生成文件项目操作"rnrn如何解决啊?
ios宏定义的参数 编译可以通过,但是提示有错误
Last login: Thu Jun 16 18:31:17 on ttys000 localhost:~ fn-118$ cd /Users/fn-118/Library/Developer/Xcode/DerivedData localhost:DerivedData fn-118$ rm -rf * rm: imeeta-bhqgfwjztyzmrgdxybejsodpt
编译通过 但是运行有一点小问题
以下是我写的快速排序的算法[code=C/C++]#includern#includern#includern#includernusing namespace std;rnvoid Quicksort(vector &arr, int first,int last)rnrn int pivot = arr[first];rn int high = last;rn int low = first + 1;rnrn if(first > last)rn rn return;rn rn while(low < high)rn rn while( low <= high && arr[low] <= pivot )rn rn low++;rn rn while(low <= high && arr[high] >= pivot)rn rn high--;rn rn if(high > low)rn rn int temp = arr[high];rn arr[high] = arr[low];rn arr[low] = temp;rn rn rn while(high > first && arr[high] >= pivot)rn high--;rn if(arr[high]<=pivot)rn rn int temp = arr[high];rn arr[high] = arr[first];rn arr[first] = temp;rn rn Quicksort(arr, first, high - 1);rn Quicksort(arr, high + 1 , last);rn rnrnint main()rnrn srand(time(0));rn vector elem(10);rn for(int i = 0; i < 20; i++)rn rn elem[i] = rand()%100;rn cout<
通过编译了但是无法运行
这是CStyleView文件内的代码rnrn#include "stdafx.h"rn#include "Style.h"rnrn#include "StyleDoc.h"rn#include "StyleView.h"rnrnrn#include "MainFrm.h"rnrn#ifdef _DEBUGrn#define new DEBUG_NEWrn#undef THIS_FILErnstatic char THIS_FILE[] = __FILE__;rn#endifrnrn/////////////////////////////////////////////////////////////////////////////rn// CStyleViewrnrnIMPLEMENT_DYNCREATE(CStyleView, CView)rnrnBEGIN_MESSAGE_MAP(CStyleView, CView)rn //AFX_MSG_MAP(CStyleView)rn ON_WM_CREATE()rn ON_WM_CANCELMODE()rn ON_WM_MOUSEMOVE()rn //AFX_MSG_MAPrn // Standard printing commandsrn ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)rn ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)rn ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)rnEND_MESSAGE_MAP()rnrn/////////////////////////////////////////////////////////////////////////////rn// CStyleView construction/destructionrnrnCStyleView::CStyleView()rnrn // TODO: add construction code herernrnrnrnCStyleView::~CStyleView()rnrnrnrnBOOL CStyleView::PreCreateWindow(CREATESTRUCT& cs)rnrn // TODO: Modify the Window class or styles here by modifyingrn // the CREATESTRUCT csrnrn //cs.lpszClass="sunxin.org";rn// cs.lpszClass=AfxRegisterWndClass(CS_HREDRAW | CS_HREDRAW,rn// LoadCursor(NULL,IDC_CROSS),(HBRUSH)GetStockObject(BLACK_BRUSH),0);rnrn cs.lpszClass=AfxRegisterWndClass(CS_HREDRAW | CS_HREDRAW);//缺省状态下rnrn rn return CView::PreCreateWindow(cs);rnrnrn/////////////////////////////////////////////////////////////////////////////rn// CStyleView drawingrnrnvoid CStyleView::OnDraw(CDC* pDC)rnrn CStyleDoc* pDoc = GetDocument();rn ASSERT_VALID(pDoc);rn // TODO: add draw code for native data herernrnrn/////////////////////////////////////////////////////////////////////////////rn// CStyleView printingrnrnBOOL CStyleView::OnPreparePrinting(CPrintInfo* pInfo)rnrn // default preparationrn return DoPreparePrinting(pInfo);rnrnrnvoid CStyleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)rnrn // TODO: add extra initialization before printingrnrnrnvoid CStyleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)rnrn // TODO: add cleanup after printingrnrnrn/////////////////////////////////////////////////////////////////////////////rn// CStyleView diagnosticsrnrn#ifdef _DEBUGrnvoid CStyleView::AssertValid() constrnrn CView::AssertValid();rnrnrnvoid CStyleView::Dump(CDumpContext& dc) constrnrn CView::Dump(dc);rnrnrnCStyleDoc* CStyleView::GetDocument() // non-debug version is inlinernrn ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStyleDoc)));rn return (CStyleDoc*)m_pDocument;rnrn#endif //_DEBUGrnrn/////////////////////////////////////////////////////////////////////////////rn// CStyleView message handlersrnrnint CStyleView::OnCreate(LPCREATESTRUCT lpCreateStruct) rnrn if (CView::OnCreate(lpCreateStruct) == -1)rn return -1;rn rn // TODO: Add your specialized creation code herern return 0;rnrnrnrnrnvoid CStyleView::OnMouseMove(UINT nFlags, CPoint point) //问题好像出现在这个函数里面,但是由于才学了没多久不知 道是缺什么造成的rnrn // TODO: Add your message handler code here and/or call defaultrn CString str;rn str.Format("x=%d,y=%d",point.x,point.y);rn ((CMainFrame* )GetParent()) -> m_wndStatusBar.SetWindowText(str);rnrn CView::OnMouseMove(nFlags, point);rnrn
编译通过但是运行不了??
使用javac编译通过了,但是使用java运行不了。出现如下的错误信息:Exception in thread "main" java.lang.NoClassDefFoundError:BubbleSort.哪位高手指点一下啊,谢谢.
java编译能通过 运行出错
各位大侠帮忙看下是哪里出错了 小弟不才 菜鸟一枚 望各位不吝赐教rn[code=Java]import java.awt.*;rnimport java.awt.event.*;rnimport javax.swing.*;rnpublic class PanelDemo extends JFrame implements ActionListenerrn private JButton oneButton,twoButton,threeButton,fourButton,fiveButton;rn private JLabel Label;rn private BorderLayout layout;rn public PanelDemo()rn setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn setTitle("JPanelDemo");rn setSize(400,200);rn layout = new BorderLayout();rn Container cp = getContentPane();rn cp.setLayout(layout);rn oneButton = new JButton("Button one");rn twoButton = new JButton("Button two");rn threeButton = new JButton("Button three");rn fourButton = new JButton("Button four");rn fiveButton = new JButton("Button five");rn JPanel pNorth = new JPanel();//添加第一个面板,放在窗体的顶部(North)rn pNorth.add(oneButton);//此面板放置oneButton和twoButtonrn pNorth.add(twoButton);rn cp.add(pNorth,"North");rn JPanel pSouth = new JPanel();//添加第二面板,放在窗体的底部(South)rn pSouth.add(threeButton);//此面板里放置threeButton fourButton fiveButtonrn pSouth.add(fourButton);rn pSouth.add(fiveButton);rn cp.add(pSouth,"south");rn Label = new JLabel("中区是JLabel组件,显示您单击了哪一个按钮",JLabel.CENTER);rn cp.add(Label,"Center");rn oneButton.addActionListener(this);rn twoButton.addActionListener(this);rn threeButton.addActionListener(this);rn fourButton.addActionListener(this);rn fiveButton.addActionListener(this);rn rn public void actionPerformed(ActionEvent e)rn Object source = e.getSource();rn if(source == oneButton) Label.setText("您单击了Button one 按钮");rn else if(source == twoButton)Label.setText("您单击了Button two按钮");rn else if(source == threeButton)Label.setText("您单击了 Button three 按钮");rn else if(source == fourButton)Label.setText("您单击了Button four按钮");rn else if(source == fiveButton)Label.setText("您单击了Button five按钮");rn rn public static void main(String[] args)rn JFrame Frame = new PanelDemo();rn Frame.show();rn rn[/code]
编译HELLOWORLD 时候正确,运行时候提示下面错误 , 不懂!!
编译HELLOWORLD 时候正确,运行时候提示下面错误 , 不懂!!rnrnrnjava.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!rn at sun.awt.image.ShortInterleavedRaster.getDataElements(ShortInterleavedRaster.java:221)rn at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(CustomComponent.java:104)rn at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:526)rn at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:191)rn at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)rn at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:821)rn at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:444)rn at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:70)rn at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:892)rn at sun.java2d.SunGraphics2D.copyImage(SunGraphics2D.java:2777)rn at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2915)rn at sun.awt.image.ImageRepresentation.drawToBufImage(ImageRepresentation.java:792)rn at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:899)rn at sun.java2d.SunGraphics2D.copyImage(SunGraphics2D.java:2777)rn at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2808)rn at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2763)rn at com.sun.kvem.ObservableGraphics.drawImage(ObservableGraphics.java:334)rn at com.sun.kvem.Icon.paint(Icon.java:171)rn at com.sun.kvem.ScreenImpl.updateFace(ScreenImpl.java:281)rn at com.sun.kvem.ScreenImpl.initialize(ScreenImpl.java:229)rn at com.sun.kvem.Screen.getInstance(Screen.java:82)rn at com.sun.kvem.EMDevice.(EMDevice.java:205)rn at com.sun.kvem.midp.MIDP$DeviceFrame.(MIDP.java:213)rn at com.sun.kvem.midp.MIDP.run(MIDP.java:480)rn at com.sun.kvem.environment.EmulatorInvoker.runEmulatorImpl(EmulatorInvoker.java:116)rn at com.sun.kvem.environment.EmulatorInvoker.runEmulatorSameVM(EmulatorInvoker.java:105)rn at com.sun.kvem.environment.EmulatorInvoker.runEmulator(EmulatorInvoker.java:63)rn at com.sun.kvem.environment.ProfileEnvironment$KVMThread.runEmulator(ProfileEnvironment.java:230)rn at com.sun.kvem.environment.ProfileEnvironment$KVMThread.run(ProfileEnvironment.java:252)rn
linphonec编译通过,但是运行的时候却提示很多错误......请高手看看
root@yhb-virtual-machine:/home/yhb/linphone/x86_target/bin# linphonecrnALSA lib conf.c:4630:(snd_config_expand) Unknown parameters 0rnALSA lib control.c:882:(snd_ctl_open_noupdate) Invalid CTL default:0rnALSA lib conf.c:4630:(snd_config_expand) Unknown parameters 0rnALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM default:0rnALSA lib conf.c:4630:(snd_config_expand) Unknown parameters 0rnALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM default:0rnReadyrnWarning: video is disabled in linphonec, use -V or -C or -D to enable.rnlinphonec> rnrnrn请问以上错误如何解决?rnrn另外不知道命令行的linphonec如何使用,有的知道麻烦告诉一下。
导入开源安卓项目,为何编译能通过,但是运行的时候一直报xml错误啊
导入开源安卓项目,为何编译能通过,但是运行的时候一直报xml错误啊  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.genius.demo/com.genius.demo.MusicPlayActivity}: android.view.InflateException: Binary XML fil
请教各位高手!!.asp页面html中编译能通过,但是运行有错误!!!!
请教各位高手!!.asp页面html中编译能通过,但是运行有错误!!!!rn提示:rnrn rn rn rnrn编译能通过说明页面没问题吧?这错到底处在哪????????急!!!!!!!!!!
cmd下java程序编译能通过但是运行不了出异常
package wcl;rnrnimport java.io.File;rnimport java.io.IOException;rnrnpublic class TestFile rn public static void main(String[] args)rn File dir = new File("."+File.separator+"demo");rn if(!dir.exists())rn dir.mkdirs();rn rn File file = new File(dir,"demo.text");rn if(!file.exists())rn try rn file.createNewFile();rn catch (IOException e) rn e.printStackTrace();rn rn rn System.out.println(file.getAbsolutePath());rn System.out.println(file.getName());rn rnrn此程序在C盘下 wcl文件夹内rn这个程序在Myeclipse里运行正常rn但是在cmd下编译通过运行不了出异常:rnC:\>cd wclrnrnC:\wcl>javac TestFile.javarnrnC:\wcl>java TestFilernException in thread "main" java.lang.NoClassDefFoundError: TestFile (wrong name:rn wcl/TestFile)rn at java.lang.ClassLoader.defineClass1(Native Method)rn at java.lang.ClassLoader.defineClass(Unknown Source)rn at java.security.SecureClassLoader.defineClass(Unknown Source)rn at java.net.URLClassLoader.defineClass(Unknown Source)rn at java.net.URLClassLoader.access$100(Unknown Source)rn at java.net.URLClassLoader$1.run(Unknown Source)rn at java.net.URLClassLoader$1.run(Unknown Source)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)rn检查过环境变量配置。在cmd上输入java -version , java ,javac 命令 都是正常的rn实在是找不到解决问题的方法 求救!
编译能通过 但是运行出错 大家遇到过吗
vs2005 环境 在我的机子上编译能通过 运行也没问题,但是换成了另外一台机子 编译也没错误 一运行就崩溃 dll什么的肯定都没问题 rn应该是两台机子的编译环境不一样(也就是2005的补丁什么的不一样),大家遇到过这种情况吗?原来都没出现过这种问题,但这次不知道为什么出现了 是不是要做什么设置
mfc调试时候编译通过但是内存错误?
[code=c]void CMFCApplication2Dlg::OnBnClickedBm()rnrn // TODO: 在此添加控件通知处理程序代码rn rn IplImage * img1 = cvLoadImage((LPSTR)(LPCTSTR)strFileName1,0);rn IplImage * img2 = cvLoadImage((LPSTR)(LPCTSTR)strFileName2,0);rn cv::StereoSGBM sgbm; rn int SADWindowSize = 9; rn sgbm.preFilterCap = 63; rn sgbm.SADWindowSize = SADWindowSize > 0 ? SADWindowSize : 3; rn int cn = img1->nChannels; rn int numberOfDisparities=64; rn sgbm.P1 = 8*cn*sgbm.SADWindowSize*sgbm.SADWindowSize; rn sgbm.P2 = 32*cn*sgbm.SADWindowSize*sgbm.SADWindowSize; rn sgbm.minDisparity = 0; rn sgbm.numberOfDisparities = numberOfDisparities; rn sgbm.uniquenessRatio = 10; rn sgbm.speckleWindowSize = 100; rn sgbm.speckleRange = 32; rn sgbm.disp12MaxDiff = 1; rn Mat disp, disp8; rn int64 t = getTickCount(); rn sgbm((Mat)img1, (Mat)img2, disp); rn t = getTickCount() - t; rn cout<<"Time elapsed:"<
程序编译没有错误但是运行后提示0x0000005
#includern#includernrnmain()rnrnrule *Rule,*R;rnint i=0;rnInit();rnwhile(*Str[i]) /*激活事实对象集*/rnrn Fact[i]=new fact((i+1), Str[i]);rn Fact[i]->PutSign(Sign[i]);rn i++;rnrnfor(int s=0;sInput=Input[s];rn Fact[s]->PutFunc(Fuzz[s]);rnrnRule=NULL;rnfor(i=RULE_LENGTH;i!=0;) /*激活规则对象集*/rnrn if(i<0) return FALSE;rn i++;rn R=new rule(Rulep[i],Rulec[i],Rule_CF[i]);rn R->Next=Rule;rn Rule=R;rnrnR=Rule;rnfor(;;)rnrn if(R->Query())break;rn R=R->Next;rn if(!R) break;rnrnfor(i=0;iGetCF()>LIMIT&&Fact[i]->GetSign()==1)rn rn Fact[i]->PutSign(0);rn cout<GetName();rn cout<GetCF();rn rnrncout<rn#include rn#include rn#include rn#include rnclass fact /*定义事实类*/rnrnprivate:rn int Number; /*事实编号*/rn char *Name; /*事实内容*/rn double CF; /*事实可信度*/rn int Active; /*记录事实的激活状态*/rn int Sign ; /*输出标记*/rn double (*Fuzz)(int i); /*定义可信度模糊函数*/rnpublic: rn void (*Input)(int); /*输入函数*/rn fact(int Num,char *L) /*初始化事卖*/rn rn Name=(char*)malloc(strlen(L)+1);rn strcpy(Name,L);rn Number=Num;rn Active=FALSE;rn CF=0;rn Sign=0;rn ;rnchar* GetName()rn rn char *L;rn L=new char(strlen(Name)+1);rn if(L!=NULL) strcpy(L,Name);rn return L;rn rnint GetNumber()rnreturn Number;rnrnrnrnrnrnrn int GetAct()rn return Active;rn void PutAct(const int Act)rn Active=Act; rn void PutFunc(double(*f)(int))rn Fuzz=f;rn double GetCF()rn return CF;rn double PutCF(int i) /*处理用户输入*/ rn CF =Fuzz(i);rn return CF;rn void PutCF(double d) /*置可信度计算结果标记*/rn CF=d;rn void PutSign(int i)rn Sign=i;rn int GetSign()rn return Sign;rn;rnfact *Fact[FACT_LENGTH+1];rnrnclass rule /*定义规则类*/rn rnprivate:rn char *Name; /*规则名*/rn int List[PRMS_LENGTH]; /*同一规则的所有俞提链表*/rn int Logic; /*定义规则间的理辑关系*/rn int Conc; /*规则结论*/rn double RCFi; /*规则可信度’*/rnpublic:rn rule *Next;rn rule(const int P[],int C[],double Rule_CF);rn ~rule();rn int Query();rn char *GetName()return Name;;rn double CF();rn int GetConc() return Conc;;rn;rndouble Max(double a,double b) /*可信度计算*/rnreturn(a>b? a:b);;rndouble Min(double a,double b)rn return(a>b? b:a);rndouble Mix(double x,double y)rnrnrnrnrnreturn (x+y-x*y);rnrnrule::~rule() /*构造释放规则空间函数*/rnrn delete Name;rn delete []List;rnrnrule::rule(const int P[],int C[],double Rule_CF) /*构造规函数*/rnrn List[0]=P[0];rn List[1]=P[1];rn Logic=C[1];rn Conc=C[0];rn RCFi=Rule_CF;rn;rnint rule::Query() /*构造推理函数*/rnrn int sign=0;rn char *choose;rn char temps[10];rn choose=new char(4);rn fact *(*temp)=Fact;rn while(signGetNumber()==List[sign])rn break;rn if((*temp)==NULL) return FALSE;rn if((*temp)->GetAct()>0)rn sign++;rn temp=Fact;rn elsern rn (*temp)->Input((*temp)->GetNumber());rn scanf("%s",choose);rn flushall();rn cout<PutCF(atoi(choose))==atoi(Repeat))rn continue; rn (*temp)->PutAct(TRUE);rnrnrnrnrn rn rn for(temp=Fact;(*temp)!=NULL;temp++)rn if((*temp)->GetNumber()==Conc)rn break;rn if((*temp)==NULL) return FALSE;rn (*temp)->PutCF(Mix((*temp)->GetCF(),CF()));rn (*temp)->PutAct(1);rn return FALSE;rn;rndouble rule::CF() /*构造可信度推理函数*/rnrn double i;rn if(Logic)rn i=Min(Fact[List[0]-1]->GetCF(),rn Fact[List[1]-1]->GetCF());rn i=i*RCFi;rn return i;rn elsern i=Max(Fact[List[0]-1]->GetCF(),rn Fact[List[1]-1]->GetCF());rn i=i*RCFi;rn return i;rn;rn/*初始化函数*/rnvoid Init()rnrn DefFuncArray();rn DefInput();rn DefRule_CF();rn Fact[FACT_LENGTH]=NULL;rnrn#endifrnrnrnrn#define kb_hrn#include rn#include rn#include rn#include rn#include rn#define TRUE 1 /*定义返回值*/rn#define FALSE 0rn#define FACT_LENGTH 9 /*前提与结论总数*/rn#define PRMS_LENGTH 2 /*每条规则的前提个数*/rn#define PREMISE 7 /*前提数量*/rn#define RULE_LENGTH 4 /*规则数量*/rn#define LIMIT 0.50 /*结论阐值*/rn#define AND 1 /*规则前提逻辑关系*/rn#define OR 0rn#define VH 0.9 /*规则前提可信度初始化*/rn#define H 0.7rn#define M 0.5rndouble Rule_CF[RULE_LENGTH];rndouble (*Fuzz[6])(int);rnvoid (*Input[6])(int);rnchar *Repeat="-111"; /*重新输入变量*/rn/*知识表达*/rnchar *Str[FACT_LENGTH+1]="E1","E2","E3","E4","E5","E6","E7","H1","H","\0";rnrnint Sign[FACT_LENGTH]=0,0,0,0,0,0,0,0,1 ;rnrnint Rulep[RULE_LENGTH][PRMS_LENGTH+1]=1,2,0,4,5,0,6,8,0, 3,7,0;rnrnint Rulec[RULE_LENGTH][2]=9,AND,8,AND,7,AND,9,OR;rnrn/*提示用户输入及处理*/rnvoid Inputl(int i)rnrn cout<45)rn cerr<<"请重新输入!";rn return atoi(Repeat);rn double i=(sign-37.0)/9.0;rn return (i>0? i:-i);rnrndouble Fuzz3(int sign)rnrnif(sign<60||sign>160)rn cerr<<"请重新输入!";rn return atoi(Repeat);rn double i,x;rn i=(sign-60.0)/100.0;rn return (i);rnrnvoid DefFuncArray()rnrn for(int i=0;i<=3;i++)rn Fuzz[i]=Fuzz1;rn Fuzz[4]=Fuzz2;rn Fuzz[5]=Fuzz3;rnrnvoid DefInput()rnrn for(int i=0;i<=3;i++)rn Input[i]=Inputl;rn Input[4]=Input2;rn Input[5]=Input3;rn rn/* 定义规则的可信度 */rnvoid DefRule_CF()rn Rule_CF[0]=0.9;rn Rule_CF[1]=1.0;rn Rule_CF[2]=0.9;rn Rule_CF[3]=0.9;rn#endifrnrnrnrn以上是我的程序
vc6.0win32 Debug编写的程序,可以运行无错误。但是win32 Release编译通过,运行的时候出现错误。
跳出错误窗口:rnRuntime Error!rnR6016rn-not enough space for thread datarn本人初次接触这种错误,希望大侠可以帮我解决,谢谢!
编译的时候有个错误
error C2440: 'initializing' : cannot convert from 'unsigned short' to 'char *'rn Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style castrn上面是错误的 部分代码如下的rnvoid CImageSampleDlg::DisplayImageBuffer(USHORT *pBuffer) rn // Create image - (buffer without header bytes)rn rn int i = 0, p;rn for (p=0; p<(129*NDH_MODULES*NSP_MODULES) * m_ImgHeight; p++) rn if ((p%129)!=0) // Skip header pixelsrn m_pImage[i] = pBuffer[p]; rn i++;rn rn rnrnrnchar bmpName[]="C:\\MyBitmap.bmp";rn[color=#FF0000]char *imgBuf= m_pImage[i];//m_pImage;[/color]int width=128*NDH_MODULES*NSP_MODULES;rnint height=m_ImgHeight;rnRGBQUAD *pColorTable=0;rnint bitcount=24;rnSave();//lilin bmpName, imgBuf, width, height, pColorTable, bitcountrnrnrn // If dual energy then sort imagern if (m_bchkDualEnergy) rn DESplitImage(m_pImage, m_ImgHeight);rnrnrn // Normalise image rn int o;rn long v;rn for (int l=0;l65534) v = 65534;rn if (v<0) v = 0;rnrn // Save normalised pixel 获得像素值吧(内存里面的 未显示的)rn m_pImage[o] = (USHORT)v;rn rnrn rnrn // Create 8 bit colour bitmap from look-up-table for display 显示的像素值 这两个有什么区别的 SetDIBitsrn for (p=0;p<(128*NDH_MODULES*NSP_MODULES)*m_ImgHeight;p++)rn m_pDispImage[p] = m_pLUT[m_pImage[p]];rn rn DrawBitmapOnScreen(); rn rn
helloworld编译成功,但是运行的时候出错。
public class helloworldrn public static void mainrn System.out.println("aaa");rn rnrnjavac helloworld成功rn但是java helloworld失败rn错误说,exception in thread "main" java.long.noclassdeffounderror:helloworld/classrn各位大虾帮帮我。
求助,编译qt可以通过,但是运行时有错误!
背景介绍:rn1.定义了一个主窗口类MainWindow,还定义了另一个划线的类DrawLine。rn2.DrawLine类的头文件包含在mainWindow.h文件中。rn3.在MainWindow类中重写了mousePressEvent,mouseReleaseEvnt和mouseMoveEvent这三个函数,这三个函数用到了类DrawLine类中的成员函数。rnrn问题如下:rn1.编译程序没有问题,也可以运行,主窗口会出现,但是,当点击鼠标开始划线的时候,rn程序就异常中断了。rn2.我现在也不太清楚问题是不是出在三个重写的函数上,还是程序的设计思路本身就有错误,或者rn还有其他的什么错误没有考虑到。rnrn请求高手指点迷津~~
提示找不到文件,但是编译通过。。。
1.提示找不到文件,但是编译通过。一般是配置工程时,头文件路径没有定义完整。 2.在keil左侧的项目管理中鼠标右键单击该文件并选择“Options for File &quot;xxx.c&quot;”,然后在对话框中勾选“include in target build”,要让其对勾变为黑色,默认是灰色。然后再编译即可。                                              ...
静态库能编译通过,但是动态库出错。
//fdb_visit.cpprn#include rn#include rn#include "open_olf_cim_db_dec.h"rn#include "open_olf_cim_db.h"rn#include "fdb_visit.h"rnusing namespace std;rnvoid fdb_visit()rnrn dbCursor busbar;rn rn int n = busbar.select();rn if( n ==0 )rn return;rn dorn cout<<"name is "<name<::~dbCursor(void)" (??1?$dbCursor@VBusbarSection@@@@QAE@XZ) 中被引用rnfdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) protected: __thiscall dbAnyCursor::dbAnyCursor(class dbTableDescriptor &,enum dbCursorType,unsigned char *)" (__imp_??0dbAnyCursor@@IAE@AAVdbTableDescriptor@@W4dbCursorType@@PAE@Z) ,该符号在函数 "public: __thiscall dbCursor::dbCursor(enum dbCursorType)" (??0?$dbCursor@VBusbarSection@@@@QAE@W4dbCursorType@@@Z) 中被引用rnfdb_visit.obj : error LNK2001: 无法解析的外部符号 "public: static class dbTableDescriptor BusbarSection::dbDescriptor" (?dbDescriptor@BusbarSection@@2VdbTableDescriptor@@A)rnfdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall dbAnyCursor::fetch(void)" (__imp_?fetch@dbAnyCursor@@QAEXXZ) ,该符号在函数 "public: class BusbarSection * __thiscall dbCursor::next(void)" (?next@?$dbCursor@VBusbarSection@@@@QAEPAVBusbarSection@@XZ) 中被引用rnfdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) protected: bool __thiscall dbAnyCursor::gotoNext(void)" (__imp_?gotoNext@dbAnyCursor@@IAE_NXZ) ,该符号在函数 "public: class BusbarSection * __thiscall dbCursor::next(void)" (?next@?$dbCursor@VBusbarSection@@@@QAEPAVBusbarSection@@XZ) 中被引用rnDebug/fdb_dll.dll : fatal error LNK1120: 6 个无法解析的外部命令rn其中dbCursor的定义如下rntemplaternclass dbCursor : public dbAnyCursor rn protected:rn T record;rn rn public:rn /**rn * Cursor constructorrn * @param type cursor type (dbCursorViewOnly by default)rn */rn dbCursor(dbCursorType type = dbCursorViewOnly) rn : dbAnyCursor(T::dbDescriptor, type, (byte*)&record) rnrn /**rn * Cursor constructor with explicit specification of database.rn * This cursor should be used for unassigned tables. rn * @param aDb database in which table lookup is performedrn * @param type cursor type (dbCursorViewOnly by default)rn */rn dbCursor(dbDatabase* aDb, dbCursorType type = dbCursorViewOnly)rn : dbAnyCursor(T::dbDescriptor, type, (byte*)&record)rn rn db = aDb;rn dbTableDescriptor* theTable = db->lookupTable(table);rn if (theTable != NULL) rn table = theTable;rn rn
编译能通过,但是连接报错
事情是这样的:rn我在使用VC6.0的MFC向导程序生成文件后编译连接执行都没问题。可是,当我退出VC后,找到该工程文件,打开主.cpp文件后并在编译后(此时提示要我建立工程,我点确定),我再把在该工程文件夹内的其他.CPP和.H的文件添加到工程,编译能通过,但是连接报错。rn我想问下,1.是我打开错了,不能这样打开?2.是我设置错了?怎么设置呢?3.利用向导程序来编写程序是怎么编写的?这个向导程序只是个示例吗?如果有编写步骤,可否告之呢?谢谢,谢谢!
程序能编译,但是不能运行,怎么回事?
我是一个刚刚学JAVA的菜鸟,我装了JDK1.3,在C盘中,源程序文件夹在D盘,AUTOEXEC。BAT设置为path=c:\jdk1.3\binrn set classpath=d:\myprogramrn发现我输入源程序后能编译成功,但是运行时显示:rnerror opening registry key"software\javasoft\java runtime envirnmentrn还说找不到运行环境,找不到JAVA。DLLrn这是怎么回事?我买的是正版软件呀
编译出现问题,但是5rd还是能运行
大家好,我在用qt做symbian开发的时候出现问题,求救啊,不知道怎么解决。rnrnrnrn *** No rule to make target `winscw_deployment'. Stop. wiggly line 0 C/C++ Problemrnrn *** No rule to make target `pre_targetdeps'. Stop. wiggly line 0 C/C++ Problemrnrn *** No rule to make target `finalize'. Stop. wiggly line 0 C/C++ Problemrnrn *** No rule to make target `winscw_deployment'. Stop. wiggly line 0 C/C++ Problemrnrnrnrnrn呜呜!!!rnrn
下面程序通过编译了,但是无法运行
#pragma warning (disable: 4786)rn#include rn#include rn#include rnusing namespace std;rntypedef struct tagStudentInfornrn int nid;rn string strname ;rn bool operator < (tagStudentInfo const& _A) const;rnStudentInfo;rnint main()rnrn mapmapStudent;rn map::iterator iter ;rn StudentInfo studentInfo;rn studentInfo.nid=1;rn studentInfo.strname="student_one";rn mapStudent.insert(pair(studentInfo,90));rn studentInfo.nid=2;rn studentInfo.strname="student_two";rn mapStudent.insert(pair(studentInfo,80));rn for(iter=mapStudent.begin();iter!=mapStudent.end();iter++)rn rn cout<< iter->first.nid << endl << iter->first.strname << endl<< iter->second <
win32程序编译通过,但是不能运行
[code=c]#includernint WinMain(HINSTANCE hInstance,rn HINSTANCE hPrevInstance,rn PSTR szCmdLine,rn int iCmdShow)rnrn MessageBox(NULL,TEXT("Hello Windows 98"),TEXT("Hello!"),MB_OK);rn return 0;rn[/code]rn运行显示错误提示为rn[code=c]Linking...rnLIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _mainrnDebug/win32.exe : fatal error LNK1120: 1 unresolved externalsrn执行 link.exe 时出错.rnCreating browse info file...rnrnwin32.exe - 1 error(s), 0 warning(s)rn[/code]
VFP编译通过但是不能运行????
接到一个VFP的程序,但我是第一次接触VFP的程序,生成。EXE的文件双击后,文件只是晃了一下,就退出了,但是在VFP下双击旧可以,生成。APP的程序旧可以,有请各位高手帮助,我的电话是8008920001,是公司的免费电话,是全国的,希望能给我解答,我叫单乐(ShanLe)。谢谢
程序编译通过但是运行失败
void main()rnrnint x,m,h;rncout<<"求1到m的和,输入m:"<>m;rnfor(x=1;x
装载问题编译通过但是无法运行
rn[code=C/C++]rn#includern#include rnusing namespace std;rnrntypedef struct QNodernrn QNode * parent;rn int LChild;rn int weight;rnQNode;rnrnvoid EnQueue(queue&q,int wt,int i,int n,int bestw,QNode *E,QNode *&bestE,int bestx[],int ch)rnrn if(i==n)rn rn if(wt==bestw)rn rn bestE=E;rn bestx[n]=ch;rn return;rn rn rn QNode *b;rn b=new QNode;//rn b->weight=wt;rn b->parent=E;rn b->LChild=ch;rn q.push(b);rnrnrnrnint MaxLoading(int w[],int c,int n,int bestx[])rnrn queue q;rn q.push(0);rn int i=1,j;rn int Ew=0,bestw=0,r=0;rn for(j=2;j<=n;j++)rn r+=w[j];rn QNode *E=0,*bestE;rn while(1)rn rn //test lchildrn int wt=Ew+w[i];rn if(wt<=c)//x[i]=1rn rn if(wt>bestw)rn bestw=wt;rn EnQueue(q,wt,i,n,bestw,E,bestE,bestx,1);rn rn rn if(Ew+r>bestw) //test rchildrn EnQueue(q,Ew,i,n,bestw,E,bestE,bestx,0);//x[i]=0rn E=q.front();rn q.pop();rn if(!E)rn rn if(q.empty())rn break;rn q.push(0);rn E=q.front();rn q.pop();rn i++;rn r-=w[i];rn rnrn Ew=E->weight;rn rn/*rn for(j=n-1;j>0;j--)rn rn bestx[j]=bestE->LChild;rn bestE=bestE->parent;rn rn*/rn return bestw;rnrnrnrnint main()rnrn int n=3;rn int c=50;//设置检测值分别为50 70 80 90 100rn int w[]=0,10,40,40;rn int bestx[100];rn cout<0;j--)rn rn bestx[j]=bestE->LChild;rn bestE=bestE->parent;rn rn*/注释了以后可以运行,给出了最佳装载值,但是如果去掉注释的话就不行了 ,无法运行。rn我觉得是q.push(0);和QNode *E=0,*bestE;的错误,因为结构体赋值于常数,结构体队列中插入常数感觉就不对,但是又不知熬怎么改。还有如果我写一个表示0的结构体,那么如何判断结构体是否相等,在c中能够用“==”直接比较。rnrnrn
编译通过但是无法运行,怎么办啊?
编译通过但是一运行exe文件就出错,exe文件停止工作,再次编译显示“ld.exe||cannot open output file E:\实验1”,怎么办啊?请各位大神指点,谢谢![img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/21.gif][/img]
asp。net编译通过,却不能正确运行,提示CGI错误。
出现下面错误提示,怎么回事啊?急啊。。。。rnThe specified CGI application misbehaved by not returning a complete set of HTTP headers.rnThe headers it did return are:rnArguments: IIS-Process-ID This-Process-Unique-ID Number-of-Sync-Pipes RPC_C_AUTHN_LEVEL_XXX RPC_C_IMP_LEVEL_XXX CPU-Mask Max-Worker-Threads Max-IO-Threadsrnrn有可能是IIS的配置问题,可是无从解决。。。
vc2005编译通过的时候没有声音提示
不知道 vc2005编译成功的时候可以不可以发给声音提示呀 我感觉听着声音好想很爽的 我想有没有告诉我怎么才能有声音
java 编译通过, 运行ClassNotfound
右击项目属性,在Java JAR Dependencies中加入缺少的类, Build Path中,加入的类,是在编译过程中起作用
pb编译通过,但是总是内存错误
用一个两层的PB基类程序进行开发rn基本开发完毕rn但是由于需要rn我在窗口基类中增加了两个按钮rn子类窗口都regenerate了rnfull build 没有错误rn但是一运行就内存错误rn而且吃的系统内存特别多,关闭程序后都还是那么多rn至少有一两百M之多rnrn而且发现rn把基类中的按钮删掉之后rn子类中的按钮虽然看不到了rn但是EDIT SOURCE依然有哪个按钮的一些相关垃圾没有删除rn不知道是不是PB的bugrnrn用的是PB9rn感觉PB9的问题还是有好多的rn而且PB一点不智能rn有时程序的确有问题,却不提示问题出在那里,只是让你不能保存.rn这点还是用java开发比较好,提示的错误信息会很快让你找到错误.rn而PB只能全部注释掉之后一行一行放开去找rn唉rnrn不知道大家有什么好方法rnrn(自己用PB有一年了,虽然算不上顶级高手,但是也有比较深的了解了,但是有时还是会被它整得焦头烂额)rn
编译没有报错,但是运行就有错误.
编译没有报错,但是运行就有错误.我是照着孙鑫教程打的代码.代码如下rn[code=C/C++]rn#include rn#include rnLRESULT CALLBACK WinSunProc(rn HWND hwnd, // handle to windowrn UINT uMsg, // message identifierrn WPARAM wParam, // first message parameterrn LPARAM lParam // second message parameterrn );rnint WINAPI WinMain(rn HINSTANCE hInstance, // handle to current instancern HINSTANCE hPrevInstance, // handle to previous instancern LPSTR lpCmdLine, // command linern int nCmdShow // show statern )rnrn WNDCLASS wndclass;rn wndclass.cbClsExtra = 0;rn wndclass.cbWndExtra = 0;rn wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);rn wndclass.hCursor = LoadCursor(NULL,IDC_APPSTARTING);rn wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);rn wndclass.hInstance = hInstance;rn wndclass.lpfnWndProc = WinSunProc;rn wndclass.lpszClassName = "first window";rn wndclass.lpszMenuName = NULL;rn wndclass.style = CS_HREDRAW | CS_VREDRAW;rn RegisterClass(&wndclass);rn HWND hwnd;rn hwnd = CreateWindow("first window","第一个c++窗口",WS_OVERLAPPEDWINDOW/*具有最小化框,rn 最大化框,标题栏菜单栏*/,100,50,rn 800,600,NULL,NULL,hInstance,NULL);rn ShowWindow(hwnd,SW_SHOWNORMAL);rn UpdateWindow(hwnd);rn MSG msg;rn while (GetMessage(&msg,NULL,0,0));rn rn TranslateMessage(&msg);rn DispatchMessage(&msg);rn rn return 0;rnrnrnLRESULT CALLBACK WinSunProc(rn HWND hwnd, // handle to windowrn UINT uMsg, // message identifierrn WPARAM wParam, // first message parameterrn LPARAM lParam // second message parameterrn )rnrn switch (uMsg)rn rn case WM_CHAR:rn char szchar[20];rn sprintf(szchar,"%d",wParam);rn MessageBox(hwnd,szchar,"测试字符串",0);rn break;rn case WM_LBUTTONDOWN:rn MessageBox(hwnd,"鼠标点击","测试鼠标点击事件",0);rn HDC hdc;rn hdc = GetDC(hwnd);rn TextOut(hdc,CW_USEDEFAULT,CW_USEDEFAULT,"单击鼠标输出文字事件",strlen("单击鼠标输出文字事件"));rn ReleaseDC(hwnd,hdc);rn break;rn case WM_PAINT:rn HDC hdc1;rn PAINTSTRUCT ps;rn hdc1 = BeginPaint(hwnd,&ps);rn TextOut(hdc1,CW_USEDEFAULT,CW_USEDEFAULT,"PAINT事件",strlen("PAINT事件"));rn EndPaint(hwnd,&ps);rn break; rn case WM_CLOSE:rn if (IDYES == MessageBox(hwnd,"要退出吗?","退出标题",MB_OKCANCEL))rn DestroyWindow(hwnd);rn break;rn case WM_DESTROY:rn PostQuitMessage(0);rn break;rn default :rn return DefWindowProc(hwnd,uMsg,wParam,lParam);rn rn return 0;rn;[/code]
编译能通过,运行时提示java.lang.VerifyError怎么办
在程序中,编译能通过,运行时提示java.lang.VerifyError怎么办
java 写的程序能通过编译但是不能执行
java程序编译之后 不能执行 会提示这样的错误rnError:missing ‘server’ jvm at D:\bin\server\jvm.dll. 求大神能提示我下 这个是什么问题
编译通过,可是运行的时候报错,求助下
编译通过,可是运行的时候报错,求助下rn我刚学网络编程,这个小程序编译没有问题 可是一旦运行就说遇到问题需要关闭。我们对此引起的不便表示抱歉。请大家指教一下!rn#pragma comment(lib, "Ws2_32.lib") rn#includern#includern#define DATA "hello.h"rnvoid main(int argc,char *argv[])rnrn int sockid; //socket号rn struct sockaddr_in server_addr; //服务器地址rn struct hostent *hp; //主机信息的结构rnrn //对socket的版本号进行协商rn WORD wVersionRequested; //需要的版本号rn WSADATA wsaData; //协商时使用的变量rn int err;rn //设置需要的版本号为1.1rn wVersionRequested=MAKEWORD(1,1);rn //启动socketrn err=WSAStartup(wVersionRequested,&wsaData);rn if(err!=0)rn rn perror("There is no DLL to use");rn return ;rn rnrn //确保Windows Socket DLL支持1.1rn if((LOBYTE(wsaData.wVersion)!=1)||(HIBYTE(wsaData.wVersion)!=1))rn rn perror("There si not right DLL");rn WSACleanup();rn return;rn rnrn //建立socketrn sockid=socket(AF_INET,SOCK_STREAM,0);rn if(sockid<0)rn rn perror("There is error in opening stream socket");rn return;rn rn //设置地址域rn server_addr.sin_family=AF_INET;rn //得到命令行中指定的服务器的名字rn hp=gethostbyname(argv[1]);rn if(hp==0)rn rn return;rn rn memcpy((char*)&server_addr.sin_addr,(char*)hp->h_addr_list,hp->h_length);rn server_addr.sin_port=htons((unsigned short)atoi(argv[2]));rn //进行连接rn if(connect(sockid,(struct sockaddr*)&server_addr,sizeof(server_addr))<0)rn rn perror("There is error in connecting stream socket");rn return;rn rn //进行发送数据rn if((send(sockid,DATA,sizeof(DATA),0))<0)rn rn perror("There is error in sending the data");rn return;rn rn elsern rn printf("Sending successfully");rn rnrn closesocket(sockid);rn WSACleanup();rn return;rn
看一下这个有什么错误,编译通过了,但是运行··
[code=C/C++]#includern#includernusing namespace std;rnint main()rnrn vector vct1(10,2);rn vector vct2;rn for(vector::iterator i=vct1.begin();i!=vct2.end();i++)rn rn vct2.push_back(*i);rnrn rn for(unsigned i=0;i!=vct2.size();i++)rn rn cout<
相关热词 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天 c#字典序排序 c# 截屏取色 c#中的哪些属于托管机制