如何创建将输出格式化为“页面”的自定义操纵器

时间:2017-01-20 06:32:12

标签: c++

我需要格式化我的输出,这样当它通过特定数量的\n时,它将通过打印到控制台'----新页面----进入“新页面”---- “

This is what i want to be displayed in my console

enter image description here

但我需要创建一个可以处理此类任务的自定义操纵器

这是我到目前为止所拥有的:

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 iAppModule。所以我的问题是:如何迭代运算符?

0 个答案:

没有答案