我想在新行打印阵列的每个插槽
i want to print every slot of my array at a new line
这是我当前的代码,我必须在新行上打印我名字的每个世界
include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int main ()
{
string a;
char j[100];
int i, c, b;
cout <<"enter your full name ";
getline(cin,a);
cout << " ur name is " << a << endl;
c=a.size();
for (b=0; b<=c; b++)
{
j[b]=a[b];
j[b]=' ';
}
system ("pause");
return 0;
}
如何在新行上打印我名字的每个部分? 例如:输入:杰罗格·阿什利·马克。 输出:乔治(换行符) 阿什利(换行)马克
这是一个
有点复杂的方法,我更喜欢评论中显示的方法。但是,如果您想避免字符串流,这是实现您正在寻找的另一种方法。它还将支持逗号分隔的名称。
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int main()
{
string a;
char j[100];
int i, c, b;
cout << "enter your full name ";
getline(cin, a);
cout << " ur name is " << a << endl;
c = a.size();
bool space = false;
for (auto iter = a.begin(); iter != a.end(); iter++)
{
if (isalpha(*iter) == false)
{
if (space == false)
{
cout << std::endl;
space = true;
}
}
else
{
cout << (*iter);
space = false;
}
}
system("pause");
return 0;
}
相关文章:
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- 如何在没有信号的情况下从C++执行QML插槽
- 从Q_INVOKABLE功能或插槽中更改QQuick图像源
- 升压信号2将插槽传递到成员功能以断开连接
- 如何在qt中将信号和插槽与另一个对象连接 --解决了
- C++ 信号和插槽不工作:插槽不响应事件
- NS3 插槽混淆(需要帮助理解)
- QObject::连接无法将信号连接到*this*对象的插槽
- QT 插槽未在主线程上调用
- 通过插槽和信号在不同线程中的两个qt对象之间进行通信
- 控制带有信号/插槽的Qt QML滑动视图
- Qt 信号/插槽问题
- QT5 信号不会激活插槽内的功能
- Qt5:连接:如果插槽的参数少于信号,如何使用"连接"
- 需要实例化不同类/对象并在启动时确定的硬件插槽的设计模式
- Qt信号和插槽如果从QRunnable或其他线程调用,则不起作用
- 如何将整个单词存储在单个阵列插槽中
- 如何在没有STL的情况下从2d阵列中删除任何未填充的插槽
- 通过Qt中的信号/插槽发送2D阵列
- 我想在新行打印阵列的每个插槽