So I have a piece of a program that creates 2D array of of characters of numbers 1 through a previously found number. Earlier in the code the total amount of numbers that needs to be cataloged is set as num_entries. I then do a basic for loop to convert integers into strings and load them into a new array(actually double pointer).
code:
Code:
int num_entries = gather_num_entries();
char *audio_nums[num_entries];
char tempchar[num_entries][2];
for(i = 0; i < num_entries; i = i + 1)
{
sprintf(tempchar[i], "%d", i);
audio_nums[i] = tempchar[i];
}
given a num_entries amount of 5 this should replicate this code:
Code:
char *audio_nums[5] = {
"0",
"1",
"2",
"3",
"4",
"5"
};
the output is really confusing me, though. It works just fine up until double digit numbers then goes off in its own little direction.
result:
Code:
1
2
3
4
5
6
7
8
9
101112131415161718
1112131415161718
12131415161718
131415161718
1415161718
15161718
161718
1718
18
Can any of you spot something I'm missing?
Thanks
-System_159