我要获取test和1这俩行的字符串然后保存到数组里面 怎么操作???

解决方案 »

  1.   

    可以用基本的C函数  fopen fgets fclose#include <stdio.h>void main( void )
    {
       FILE *stream;
       char line[100];   if( (stream = fopen( "fgets.c", "r" )) != NULL )
       {
          if( fgets( line, 100, stream ) == NULL)
             printf( "fgets error\n" );
          else
             printf( "%s", line);
          fclose( stream );
       }
    }
      

  2.   

    CStdioFile txtIn;
    if(!txtIn.Open(TransFile,CFile::modeRead |
    CFile::typeText | CFile::shareDenyNone))
    {
    AfxMessageBox("无法打开文件!");
    return;
    }
    CString OneLine;
    while(txtIn.ReadString(OneLine))
    {
    OneLine.Empty();
    }
    txtIn.Close();