如何将一个单词放入变量中
How to put a word into a var
我想设置一个程序,向一个";客户";,这个代码需要将一个名字和一个姓氏存储在一个与var竞争的结构中。但在输出时,它显示了一个数字。
#include <iostream>
using namespace std;
//DECLARATIONS
struct dates {
int emb_date;
int post_date;
};
struct info {
int nom;
int prenom;
};
void saisie_info() {
info identite;
cout << "Veuillez indiquer votre prenom : " << endl;
cin >> identite.prenom;
cout << "Veuiller maintenant insiquer votre nom : " << endl;
cin >> identite.nom;
cout << identite.prenom << " " << identite.nom << endl;
}
int main()
{
saisie_info();
}
正如你所看到的:prenom的意思是姓氏,nom的含义是名字(我是法国人(这不起作用。。。。为什么?确切地说,我别无选择,只能使用"结构"来存储";nom";以及";婚前协议";。感谢您的帮助
您必须更改struct info
中nom
和prenom
的数据类型。类型int
表示数字。字符串(或单词(在C++中用std::string
表示:
struct info {
std::string nom;
std::string prenom;
};
如果我对你的代码进行了更改,并输入了我的名字,我会在输出中看到它。
相关文章:
- OpenCV代码不会检测人脸的数量,也不会在脸周围放一个圆圈
- 我的 cout 上有一个奇怪的输出,它把答案放在第一位,然后在我调用它的地方放一个奇怪的输出.我该怎么办?
- 该程序将.csv文件中的一系列单词放入数组中,然后随机生成句子.但它不起作用
- 如何将一个单词拆分成字母,并将它们放入一个无序的列表/集合中
- 如何将行的第一个单词作为一个变量,将行的其余部分作为另一个变量进行归档/存储
- 我可以放一个lambdas的无锁队列吗?
- 对于每个单词输出一个对列表,行号和该行的字数
- 如何从C++程序中删除多个空格,并放一个空格代替它
- 什么是调试断言?如何将一行的单词放入数组中
- 给定一个单词和一个文本,返回文本中单词字谜的出现次数
- 给定一个单词和一个文本,我们需要返回字谜的出现次数
- 如何允许用户在opengl中缩放一个对象而不缩放另一个对象
- 将用户输入的前两个单词分隔一个空格,然后存储剩余短语(C++)
- 在桌面图标后面放一个窗口
- 反转每个单词在一个句子中使用c++需要代码优化我的代码片段
- 如何在C中获得一组带有空格的单词作为一个输入
- 为什么在头文件的第一行放一个随机数
- 如何将输入的句子中的单词放入数组中?C++
- 在要初始化的成员变量后面放一个括号
- 将文件中的单词放入散列映射(c++)