Click here to Skip to main content
16,015,755 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my program :
C++
#include <iostream>
#include <windows.h>
using namespace std;
void gotoxy(int a, int b){

    COORD Cord;
    Cord.X=a;
    Cord.Y=b;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Cord);
}
class pls
{
    public:
    char b[8];
};
class star
{
    public:
    pls c[8];
};

int main()
{
    star box;
    for(int i=0;i<8;i++)
    {
    box.c[i].b[i]="t";
    }
}

and the error is invalid conversion const char* to char
Posted
Updated 31-Oct-11 23:18pm
v2

1 solution

Replace
C++
box.c[i].b[i]="t";
with
C++
box.c[i].b[i]='t';
and it should work.

Please note:
The way you are using your loop only one character in each of the pls class char arrays is assigned the 't' value.
If you want to assign each character the 't' value you need to use a second loop.
C++
int main()
{
    star box;
    for(int i=0;i<8;i++)
    {
        for(int j=0;i<8;j++)
        {
            box.c[i].b[j]='t';
        }
    }
}
 
Share this answer
 
v2
Comments
Member 8325631 1-Nov-11 5:25am    
tanx to u my friend
André Kraak 1-Nov-11 5:26am    
Your welcome.
Member 8325631 1-Nov-11 5:57am    
my friend i want to write a program with class can move this
***
*+*
***
i want to move this with 2 classes i explained above tanx if u can help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900