Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
クライアントがサーバーにファイルを送信し、サーバーがファイル名を新しい場所に保存するソケットプログラムを作成しています。私の質問は、クライアントがファイル名をサーバーに渡すときに、新しい場所に同じ名前を使用してファイルを作成するにはどうすればよいですか。ファイルハンドラは次のようになります
fw=fopen("c://TestCopy","a+");
ファイルを開くために、fopenが渡されたファイル名を取得するために何をする必要がありますか。
私はここで少し混乱しています。あなたが望むのはこれだと思います:
fw = fopen(argv[1], "r"); ... // send the filename send(server, argv[1], strlen(argv[1]) + 1, 0); ...
サーバ:
... // receive the file name int fileNameLen = recv(client, buffer, maxBufferSize, 0); fopen(buffer, "w"); ...