J
Jay
How can I cast Integer value 450 to a char[10] array "450 "? in a c program?
thanks in advance for any help.
thanks in advance for any help.
Jay said:How can I cast Integer value 450 to a char[10] array "450 "? in a c program?
thanks in advance for any help.
Park Sung Jae said:sprintf, sscanf
function will help you
program?Jay said:How can I cast Integer value 450 to a char[10] array "450 "? in a c
In said:How is sscanf going to help?
In said:How can I cast Integer value 450 to a char[10] array "450 "? in a c program?
^^^^^^^^^^In said:Jay said:How can I cast Integer value 450 to a char[10] array "450 "? in a c
program?
#include <stdio.h>
int main()
{
char array[10] = {0};
int i = 450;
sprintf(array, "%d", i);
printf("%s\n", array);
return 0;
}
Jay said:How can I cast Integer value 450 to a char[10] array "450 "? in a c program?
thanks in advance for any help.
Do you mean a char[10] array *including* the tailing null character ?
Jeff said:Jay said:How can I cast Integer value 450 to a char[10] array "450 "? in a c program?
thanks in advance for any help.
Do you mean a char[10] array *including* the tailing null character ?
char array[10];
sprintf(array, "%-9d", 450);
array[9] = '\0';
In said:Jeff said:Jay said:How can I cast Integer value 450 to a char[10] array "450 "? in a c program?
thanks in advance for any help.
Do you mean a char[10] array *including* the tailing null character ?
char array[10];
sprintf(array, "%-9d", 450);
array[9] = '\0';
This answers my question, thank you all for your help.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.