【发布时间】:2021-07-27 06:52:59
【问题描述】:
我正在尝试将字符串文字与来自用户的输入结合起来,并将其作为一条消息存储在一个数组中。然后我必须将该消息发送到服务器。我还很新,对指针仍然有些困惑。 这是我迄今为止尝试过的:
char input[1000];
char filename[100];
char message[2000];
printf("Please enter the name of a file \n");
scanf("%s", filename);
printf("what would you like to write to the file ?\n");
scanf("%s",input);
message = ("Write to file %s the following input: \n", filename, input);
if (send(csocket , message , strlen(message), 0) < 0)
{
printf("send failed \n");
}
【问题讨论】:
-
欢迎来到 Stack Overflow。请注意,在这里说“谢谢”的首选方式是投票赞成好的问题和有用的答案(一旦你有足够的声誉这样做),并接受对你提出的任何问题最有帮助的答案(这也给出了你的声誉小幅提升)。请查看About 页面以及How do I ask questions here? 和What do I do when someone answers my question?
标签: arrays c string sockets pointers