C++にて、パスワードのあるサーバー上のファイルの読み取りを行いたいと考えています。
ご指摘いただいた部分について修正しました。
現状、プログラム上で呼び出したコマンドでは開けます。
.csvの実行(=エクセルの起動) : line A
データの表示 : line B
しかし、fstreamでは値の取得が出来ません。 : line D
最終的にはfstreamにて値の取得を行いたいのですが、どうすればよいのでしょうか。
ローカルファイルでは動作確認しています。(Windows 10 64bit)
どうぞよろしくお願いします。
以下ソースです。
C++
1#define _CRT_SECURE_NO_WARNINGS 2#define _USE_MATH_DEFINES 3#include <stdio.h> 4#include <math.h> 5 6#include <iostream> 7#include <string> 8#include <fstream> 9 10using namespace std; 11 12 13void main ( void ) { 14 15 system ( "net use X:\\XXX.XX.XXX.XXX\test /user:ユーザー名 パスワード" );// line A 16 system ( "type X:\test.csv " );//line B 17 std::ifstream ifs ( " X:\test.csv " );//line C 18 19 string str; 20 if ( ifs.fail () ) { 21 cout << "読み取れません" << endl;//line D 22 } 23 24 double a = 0 ; 25 while ( getline ( ifs , str ) ) { 26 a = 0.0; 27 sscanf ( str.data () , "%lf" , &a ); 28 cout << "a = " << a << endl; 29 } 30} 31 32 33
回答4件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。