注册 登录
编程论坛 C++教室

怎么输出的是数字而不是字母就解释啊是不是指针哪里用错了还是结构函数?

Onesaber 发布于 2013-04-24 10:43, 507 次点击
程序代码:
#include <iostream>
using namespace std;
class tnode
{
private:
    char *tword;
    int count;
public:
    tnode(char o[],int p)
    {
        tword  = o;
        count = p;
    }
    void out()
    {
        cout <<count<<endl;
    }
    void xout()
    {
        for(int i = 0 ; i < 10 ;  i++)
        {
            cout << *tword +i <<endl;
        };
    }
};
void main()
{   
    char x[10] = {"roor"};
    tnode io(x,6);
    io.out();
    io.xout();
}
2 回复
#2
不要脸的猫2013-04-24 11:14
*(tword+i)试试
#3
邓士林2013-04-24 11:25
for(int i = 0 ; i < 10 ;  i++)
        {
            cout << *(tword +i) <<endl;
        };
这样就好了,
1