我正在使用 CGI 和 C++ 语言。
假设我有 string str="Hello people of earth";
(这只是一个例子,字符串是动态的)
我需要将 str 设置为 html 表单中的默认值,但我得到的只是第一个单词。
cout<<"<input type=text name=word value=" << str <<">";
最佳答案
发生这种情况是因为您没有在字符串 (' ') 中给出值。所以当它到达“太空”时它就停止了。
代替这个
cout<<"<input type=text name=word value=" << str <<">";
这样试试
cout<<"<input type='text' name='word' value='" << str <<"'>";
关于html - 如何在 HTML 文本字段(表单中)中将包含空格的字符串设置为默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24182414/