1. Char array

Code:
```int main(void)
{
.
.
.
char row[15];
}

int function(char *row)
{
char numbers[16] = { "0", "1", ........"15" };

for(i=0; i<size; i++)
{
if(....= ...)
[Code help needed here! ]
}
}```
ok..i pasted a very small portion of my assignment that i'm doing...anywayz....the problem i'm have is trying to assign the "row" to a value from "numbers"....how wud i approach doing this, i tried several ways, they work, but from the numbers 1-9, any higher, it'll juz take the first number, i.e 15, will become 1.

this was one of them -> *row = *(numbers[i]); but yea, that's buggy...

2. Code:
`char numbers[16] = { "0", "1", ........"15" };`
" " is used to denote strings, a string is an array of chars.

and if u want it to read numbers try,
char numbers[16]={1,2,3,4,.....15}

3. but digits from 10 onwards are two, so i have to use " "....

i'm pretty sure, i can do " "...

4. no u cant, unless u use a pointer.
did u try compiling char numbers[15] ={"1","2"....

u will get an error.

anyways ,just use char numbers[15]={1,2,3,4...15}

this will take in both numbers.
Code:

5. Code:
`char numbers[16];`
That declares an array of 16 chars. A char can only hold one character. "15" is a 3 char array consisting of the chars '1', '5', and '\0'. It cannot fit in a char.

6. Originally Posted by qqqqxxxx
no u cant, unless u use a pointer.
did u try compiling char numbers[15] ={"1","2"....

u will get an error.

anyways ,just use char numbers[15]={1,2,3,4...15}

this will take in both numbers.
Code:

sorri, a typo! char* numbers[....]...hehe...anywayz how wud i fix it guys, thanks alot...

7. Code:
`strcpy(row_p+i,numbers+i);`

here row should be a double matrix
char row[15][3];
char (*row_p)[3] ;
row_p=row;

8. hmmm...well i only need to store only one of from 1-15...to row..so why do i need such a big array, actually cud u explain a bit about the double matrix....so it wudn't work with my way?

9. u dont need that actually,only because u r insisting on using char *numbers[15].

if u only need numbers from 1-15 ,
just use

char numbers[15]={0,1,2,3,......15}

and using a number without any quotes forces it to be stored in decimal (%d) format.

and a char is 8 bit so u can store a number using decimal format as long as it is < =127

and then u can have char row[15];

and u can do an assignment like this row[12]=numbers[15]

Code:

10. two dimensional arrays are declared like this m[2][3]

u can think of it as having 2 rows and 3 columns,so it would look somewhat like this:

xxx c0 | c1 | c2
________________________________
row0 1 | 2 | 3

row1 4 | 5 | 6

that would mean that m[0][0]==1
m[1][0]==4
m[1][1]==5 ...... and so on.

a pointer to a double matrix char m[2][3] is declared like this
char (*m_p)[3];

now,
m_p=m; //here m_p points to first row of m[2][3]

m_p+1 will point to second row of m[2][3];

so ( *(m _p+1))[0]==4 //check the parenthesis,u have to get them right everytime for
// this to be able to work.

Code:

11. try this
Code:
```char row[14];
row[12]= 15;
printf("%d",row[12]);```

here is the output:
15

12. lol..my bad, i was assiging it to the wrong array, lol..thanks alot for the help, really appreciate the quick replies! ...