从用户那里得到一个句子 [英] get a sentence from user

查看:67
本文介绍了从用户那里得到一个句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从代码块中的用户处获取字符串getch getc获得示例行,我想获取用户名,我该怎么办?

how can i get a string from user in codeblocks getch getc get line for exmaple i want to get user name what should i do?

推荐答案

getline();


例如


for example

int main () {
  char name[256], title[256];

  cout << "Enter your name: ";
  cin.getline (name,256);

  cout << "Enter your favourite movie: ";
  cin.getline (title,256);

  cout << name << "'s favourite movie is " << title;

  return 0;
}


另请参阅基本模板成员声明:


also see basic template member declarations:

typedef charT char_type;
basic_istream& getline (char_type* s, streamsize n );
basic_istream& getline (char_type* s, streamsize n, char_type delim );


这篇关于从用户那里得到一个句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆