Can any one help me put my pointer by gotoxy function inside the matrix that,s like as below:

void gotoxy( short x, short y ) // function to handle position of cursor on the screen
{

HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
COORD position = { x, y };

SetConsoleCursorPosition( hStdout, position );
}
int main()
{

    int row;
    int col;
    int *array[row][col];
    cout<<"Enter value of row and column for square matrix:"<<endl;
    cin>>row;
    cout<<endl;
    cout<<endl;
    col=row;
    int count=0;
    for (int i = 1; i <= row; i++)
    { 
      cout<<"|";
      for (int j = 1; j <= row; j++)
          {
           cout<<"---";
           for(int k=0;k<=count;k++)
           {
              cout<<"|";
              }
              }
              cout<<endl;     
              }
      system("pause");
      return 0;
     }

Recommended Answers

All 2 Replies

Not a clue what you are asking. Examples may make it clear.

Let's start at the beginning.

1.) At line 14, you declare a two-dimensional array of int-pointers using uninitialized values of row and col, so who knows how big your matrix actually is.

2.) You then input a value for row, and assign col to be the same value, in lines 16 and 19.

3.) Finally you attempt to print out a bewildering set of junk characters, presumably looking something like:

|---|---|---|---|
|---|---|---|---|
...

... except you loop j over "row" instead of "col" (even though they're the same in this case, it's still silly); i can't tell why you loop k over [0,count] where count is also zero, is this so you can print more than one separator between successive vals in a row?; and you never reference your array of int-pointers at all. Of course that last point isn't an issue, since you also never fill your array with any values. And if you want it to store integers, it should be declared as int array[row][col]; (note, I removed the "*").

Also, note that Narue added [ CODE ] tags for you. Please do this yourself in the future. Use the "[ CODE ]" icon-button at the top of the editor. You have three options:
1) click the button first, then paste your code in between the start-tag and end-tag
2) paste your code first, then select it all and click the button
3) hand-type the tags yourself
whichever best suits your style.

Now after all that, what was the question?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.