gpt4 book ai didi

html - 如何在 C 中打印前斜杠?

转载 作者:太空宇宙 更新时间:2023-11-04 03:35:34 25 4
gpt4 key购买 nike

您好,我在我的 html 文件上打印前斜杠 '/' 时遇到问题,我需要从选择的输入中收集数据并将值发送到我的 .cgi 文件,但是当我选择像“/home”这样的值时,它会打印出来“%2Fhome” 我该如何解决这个问题?谢谢你的回答..

Shell: <select name=shell>
<option value="/bin/bash">/bin/bash</option>
<option value="/bin/sh">/bin/sh</option>
<option value="/usr/bin/csh">/usr/bin/csh</option>
<option value="/bin/false">/bin/false</option>
</select><br>

最佳答案

下面的代码读取并打印以终止传递的文件。已使用您的文字进行测试。

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
FILE *fd;

if (argc < 2)
{
return EXIT_FAILURE;
}

// Open requested file
fd = fopen(argv[1], "rb");

// Check file opened
if ( fd == NULL )
{
// Couldn't open file
return EXIT_FAILURE;
}

// Step through the file until EOF occurs
int c;
while ((c = fgetc(fd)) != EOF) {
printf("%c", c);
}

// Close file
fclose(fd);

return EXIT_SUCCESS;
}

用命令编译它:gcc -o test test.c -Wall -std=c99

然后调用它为:./test test.txt

关于html - 如何在 C 中打印前斜杠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33009423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com