Coder's Guild Mailing List

Re: filling a matrix

Posted by Bernie Siegrist on 2000-05-01

Date: Sun, 30 Apr 2000 09:05:20 +0100
From: "Mark Burford" <mrb199@xxx.xxxxx.xx.xx>
Subject: filling a matrix

 > I have
 > [...]
 > Matrix[I][J] = StringOfChars[I];
 > [...]
 > /*Where am I going wrong?*/

You'll probably bang your head against the keyboard if you see the problem. 
:-)  You are using I to address the current element of StringOfChars. Now I 
only counts from 0 to 4, so your matrix is filled somehow like that...

A B C D E
A B C D E
A B C D E
A B C D E
A B C D E

This should work for you:
Matrix[I][J] = StringOfChars[I+J*5];


NS, I'm a lousy C programmer and might have mixed up I and J. But you'll 
find out :-)