我需要格式化我的输出,这样当它通过特定数量的\n
时,它将通过打印到控制台'----新页面----进入“新页面”---- “
This is what i want to be displayed in my console
但我需要创建一个可以处理此类任务的自定义操纵器
这是我到目前为止所拥有的:
ostream &myc (ostream &s) {
int i, j;
for(i=0; s[i]!='\0'; i++){ //this doesn't work
if (s[i] == '\n') j+=1;
if (j==2){ // each page will have only 2 lines
cout<<"\n---new page---\n";
j = 0;
}
}
cout<<s<<"\n";
return s;
}
我知道for
循环不起作用,因为no match of operator[]
因为。operator type s
我有int type i
和AppModule
。所以我的问题是:如何迭代运算符?