I asked earlier for help for strcpy. I finally realised the problem but now I have an interesting issue. During the string copy process characters will go missing, dissapearing into the ether, they seem to be counted as nulls.
this is the prepared str array:
char tline[NLINES][LMAX] = {
" first 123 and now second -.1234 and you're needing this 123.456 plus one of these +123. too",
" ellen's favourites are 123.654E-2 eg exponent-form which can also be -54321E-03 or this +432e2",
" I'll prefer numbers like ftml-dec +.1234567e+05 or fmt2-dec -765.3245 or fmtl-int -837465 or ",
" even fmt2-int -19283746 which make us think of each state's behavior for +3 or even +3471 states ",
};
and this is the result (the [] represent the nulls):
first 123 and now seccnd -.123[][][][]d you're [][][]ding this 123.456 plus one of these +123. too ellen's favourites arr 123.654[][][] eg expon[][][][]form
and so on.
Does anyone know how I can fix this fractured problem?
#define LMAX 256
#define NLINES 10
int main()
{
char tline[NLINES][LMAX] = {
" first 123 and now second -.1234 and you're needing this 123.456 plus one of these +123. too",
" ellen's favourites are 123.654E-2 eg exponent-form which can also be -54321E-03 or this +432e2",
" I'll prefer numbers like ftml-dec +.1234567e+05 or fmt2-dec -765.3245 or fmtl-int -837465 or ",
" even fmt2-int -19283746 which make us think of each state's behavior for +3 or even +3471 states ",
};
char line[LMAX];
for(int i=0; i<NLINES; i++)
{
strcpy(line,tline[i]);
}
}
If we want to copy the whole of the tline array to another one,
we would make the line array the same size as the tline array
#define LMAX 256
#define NLINES 10
int main()
{
char tline[NLINES][LMAX] = {
" first 123 and now second -.1234 and you're needing this 123.456 plus one of these +123. too",
" ellen's favourites are 123.654E-2 eg exponent-form which can also be -54321E-03 or this +432e2",
" I'll prefer numbers like ftml-dec +.1234567e+05 or fmt2-dec -765.3245 or fmtl-int -837465 or ",
" even fmt2-int -19283746 which make us think of each state's behavior for +3 or even +3471 states ",
};
char line [NLINES][LMAX];
for(int i=0; i<NLINES; i++)
{
strcpy(line[i],tline[i]);
}
}