Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 在Visual C+中进行文件到文件的数据传输+;_File_Visual C++ - Fatal编程技术网

File 在Visual C+中进行文件到文件的数据传输+;

File 在Visual C+中进行文件到文件的数据传输+;,file,visual-c++,File,Visual C++,我有一个密码: using namespace std; int main() { char Filename[100]; char st[100][100]; char *argv[100]; std::ifstream infile("data.txt"); std::freopen("output.xls","w",stdout);

我有一个密码:

    using namespace std;
    int main()
        {
              char Filename[100];
              char st[100][100];
              char *argv[100];
          std::ifstream infile("data.txt");
          std::freopen("output.xls","w",stdout);
    if (!infile)
       {
          cout << " Input file Could not open file." << endl;
          return 1;
       }
    std::string line;
    while (std::getline(infile,line))
       {   
            int a;
            int length=line.size();
            for(a=0;a<=length;a++)
              {
                     Filename[a]=line[a];
              }
       // one D array to 2D array
         int b=0;
         int l=0;
          strcpy(st[0],"0");// for erase previous value
          //cout<<st[0]<<endl;
      for(int j=0;j<=a;j++)
       {
           if (Filename[j]==' ')
             {
                    b++;
                    l=0;
                     strcpy(st[b],"0");// for erase previous value
              }
       else
        {
           st[b][l]=Filename[j];
           l++;
        }

      } //..........
    // 2D array to reffarence array.
      for(int k=0;k<=b;k++)
          {
              argv[k]=&st[k][0];
               cout<<argv[k];// or  cout<<st[k]; i get same 
               cout<<"\t";

           }
         cout<<endl;

           //..............
    // Do whatever with the array content
       }

        infile.close();


         return 0;
      }
使用名称空间std;
int main()
{
字符文件名[100];
char st[100][100];
char*argv[100];
std::ifstream infle(“data.txt”);
标准::freopen(“output.xls”,“w”,stdout);
如果(!infle)
{

cout您正在创建一个大小为100的未初始化字符数组。然后,您只在其中读取3-8个字符。但是您正在打印整个缓冲区,包括未初始化的元素。

但是在每次打印之前,我会初始化每一行。如果确实会发生这种情况,为什么不针对每一列?为什么不针对每一行的第一行?