CString str[100];
CStdioFile fs; 
fs.Open(SourPath, CFile::modeRead | CFile::typeText)
       for(int b=1;b++;b<100)
{
if(fs.ReadString(str1)==NULL)  break;
s[b]=str1;
b++;
//AfxMessageBox();



fs.Close();
for(int i=0;i++;i<100)
{
      while(s[i][n]!='\n')  对数组中的一个字符串进行处理。
    {
      switch(s[i][n])
      {
       }
      n++;
     }
}
为什么会有错误。大家帮忙看看吧,谢谢。
    

解决方案 »

  1.   

    第一个for循环里还加上一个b++我就不理解了,每隔一行读取文件?不过这个应该是小事;
    你的s二维数组不会是越界了吧?
      

  2.   

    s怎么定义的?还有,你的for循环体里的b++是不是正确的?for(int b=1;b++;b<100)
    {
    if(fs.ReadString(str1)==NULL)
    break;
    s[b]=str1;
    b++;//你确定这个b++是需要的?
    }
      

  3.   

    b++是错写了,不好意思啊,不管它的事,除了还是有错误。还是0xfffffff4
      

  4.   

    读文件的 99行吧
    for(int b=1;b++;b<100)下面处理的怎么有100行了
    for(int i=0;i++;i<100)
      

  5.   

    四行的话肯定更错了撒for(int i=0;i++;i<100)
      while(s[i][n]不错才怪.
      

  6.   

    s的定义是CString s[100];
    n的初值是零,
    我又查了一遍,没有越界。
    是不是CString s数组不能这样定义啊。
    大家帮我看看,谢谢了。
      

  7.   

    while(s[i][n]!='\n') 对数组中的一个字符串进行处理。
      {
      switch(s[i][n])
      {
      }
      n++;
      }
    -----------------------------
    我在想,它怎么能='\n'呢,不等于的话,为什么不越界呢
      

  8.   

    问题是s[5]开始里面就没数据了啊
    s[5][n]肯定报错啦
      

  9.   

    for(int b=1;b++;b<100)for(int i=0;i++;i<100)两个for循环都写错了,这样for(int b=1; b<100; b++)for(int i = 0;i < 100;i++)
      

  10.   

    呵呵,看来我编程还是不严谨啊,我是在这打字的时候写错了,程序里面没有错
    我觉得covsno说的有道理。我的文本文件行数不固定,不过一般不超过100行。
    又不会用动态数组,所以这样设的,有好的方法吗
      

  11.   

      for(int b=1;b++;b<100)
    To
      for(int b=1; b<100; b++)
      

  12.   

    叫你找‘littleC’你没找啊。
    littleC中的:///
    int load_program(char*p,char *fname)
    {
    FILE *fp;
    int i=0; if((fp=fopen(fname,"rb"))==NULL) return 0; i=0;
    do
    {
    *p=getc(fp);
    p++;i++;
    }while (!feof(fp) && i<PROG_SIZE); if(*(p-2)==0x1A) *(p-2)=0;// sz
    else             *(p-1)=0;    
    fclose(fp);
    return 1;
    }PROG_SIZE=10000
      

  13.   

    谢谢大家对我的帮助,我用的CArray类。实现了,呵呵,可以还没想好怎么使用跳转和循环。高手在给指点一下吧。
    我用的是用
    int n;
    n=0;
    CStdioFile str;
    CArray<CString,CString> FileArray
    while(fs.ReadString(str))
    {
       str+='\n'
       FileArray.Add(str);
    }
    现在把数据都存到了FileArray中。
    要是正常读取就是
    for(int i=0;i<FileArray.GetSize();i++)
    {
      while(FileArray[i][n])
      {
        switch() //判断一个字符串中的单个字符
      }
    }
    要是想执行跳转的话怎么实现啊。比说说我要跳转到第三行重新开始执行,怎么做。请高手指点。
       
      

  14.   

    用CArray类处理包装太深,看看LittleC的:/// Execute a FOR loop
    void exec_for(void)
    {
    int cond;
    char *temp,*temp2; get_token();
    eval_exp(&cond);// init exp
    if(*token != ';') sntx_err(SEMI_EXPECTED);
    prog++;// get past the ;
    temp=prog;// condition
    for(;;)// forever
    {
    eval_exp(&cond);// check condition
    if(*token != ';' ) sntx_err(SEMI_EXPECTED);
    prog++;//"ch=ch+1)  {"
    temp2=prog;// increament
    //find the start of the for block
    // if we put comments after 'for'
    // such as for() /* */
    while(token[0]!='{') get_token();
    // '{' comes
    putback();
    if(cond) 
    {
    interp_block();// true 
    }
    else
    {// skip around loop
    find_eob();
    return;
    }
    prog=temp2;
    eval_exp(&cond);//do the increment
    prog=temp;// loop back to top
    }
    } 他用的是递归,所以不需要堆栈。注意char *temp,*temp2;
    这2个变量在递归时的的作用,他们都指向源程序的某处temp指向condition(如 j<5)而temp2指向increament(即++j)
      

  15.   

    http://d.wanfangdata.com.cn/periodical_jcyyy200606076.aspx
    "STEP-NC程序解释器的研究与开发"
      

  16.   

    或者:
    http://www.lw23.com/pdf_6335cfdc-7c2e-46bb-a001-198f7e9306fb/lunwen.pdf