M
Mark
Hello,
I need to convert values from unsigned long array into char buffer, and
include one space symbol between the elements, i.e.
char buf[55];
unsigned long p[NUM] = {1, 0, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2,2, 2, 2, 2, 2, 0};
should get buf={1 0 0 0 0 1 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0}
but tricks with sprintf() don't seem to work, the target buffer doesn't
include spaces. What am I doing wrong ? Thanks.
int i;
char buf[55] = {'0'};
unsigned long p[NUM] = {1, 0, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2,2, 2, 2, 2, 2, 0};
for (i = 0; i < NUM; i++) {
int n;
n = sprintf(&buf, "%lu", p);
sprintf(&buf + n, " ");
}
I need to convert values from unsigned long array into char buffer, and
include one space symbol between the elements, i.e.
char buf[55];
unsigned long p[NUM] = {1, 0, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2,2, 2, 2, 2, 2, 0};
should get buf={1 0 0 0 0 1 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0}
but tricks with sprintf() don't seem to work, the target buffer doesn't
include spaces. What am I doing wrong ? Thanks.
int i;
char buf[55] = {'0'};
unsigned long p[NUM] = {1, 0, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2,2, 2, 2, 2, 2, 0};
for (i = 0; i < NUM; i++) {
int n;
n = sprintf(&buf, "%lu", p);
sprintf(&buf + n, " ");
}