C++获取屏幕输入
2017-09-10 11:43
357 查看
1. c++获取屏幕上一行数字的输入,以任意字符分隔,以回车结束(不需要提前知道有多少数据)
#include<iostream> #include<vector> #include<sstream> #include<stdlib.h> using namespace std; void split(const string& s, const string& delim,vector<string> &elems) { size_t pos = 0; size_t len = s.length(); size_t delim_len = delim.length(); if (delim_len == 0) return; while (pos < len) { int find_pos = s.find(delim, pos); if (find_pos < 0) { elems.push_back(s.substr(pos, len - pos)); break; } elems.push_back(s.substr(pos, find_pos - pos)); pos = find_pos + delim_len; } return; } int main() { char a[4096]; scanf("%[^\n]",a); string s(a); vector<string> s_s; split(s," ",s_s); for(int i=0;i<s_s.size();i++) cout<<s_s[i]<<endl; return 0; }
相关文章推荐
- 获取(多)屏幕尺寸--C++
- 【程序】给C++的cout和fstream添加Unicode支持,使其能向屏幕或文件输入/输出wchar_t字符串
- c++ 如何获取本地txt读取文本(不是根据控制台输入值的那种)
- c++获取屏幕大小
- 类似于QQ聊天界面的EditView输入控件点击获取焦点弹出软件盘,点击屏幕使EditView失去焦点隐藏软件盘。
- C++ 获取其他窗体编辑框输入值
- C++获取输入的空格
- C/C++获取输入时的回车问题
- C++获取控制台输入
- UE4中通C++代码获取屏幕鼠标位置
- C++ 从终端获取字符串——OJ字符串输入处理
- 文件重定向,getline()获取一样,屏幕输出流,格式控制符dec,oct,hex,精度控制setprecision(int num),设置填充,cout.width和file(字符),进制输入
- c++获取键盘输入cin、scanf使用详解
- C++ 如何一次性获取用户输入并判断是否为数字?
- [C++基础]031_如何正确获取用户的输入
- 【Linux C代码分享二】UDP Socket示例程序:使用fgets函数获取屏幕输入
- uefi获取屏幕输入
- 获取屏幕输入
- 点击屏幕其它地方,让EditText失去焦点,并获取EditText输入的类容
- Windows下C++ 模拟键盘输入,鼠标点击,鼠标移动,获取句柄