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"); ...