String Arrays..

noobcoder's Avatar, Join Date: Jul 2011
Newbie Member
Hi! Good day. Uhh..I'm still learning how to use C. I'd like to ask for help about storing arrays..
here's how it goes..

When I input a string/char I'd like to store it an array. E.G. "Hi" output will be H i. God. I'm having a hard time explaining this..

I give another example...I input Hello World the output will be.. H e l l o W o r l d

any help?
poornaMoksha's Avatar, Join Date: Jan 2011
Ambitious contributor
Follow these steps :

- Declare a character array of (say) 50 bytes
- use 'getchar()' or 'gets' to accept input.
- Store the input in array.
- Print the array (as required).
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Something like this maybe?
Code:
char *str="Hello world";
for (int i=0; str[i]; i++)
{
  putchar(str[i]);
  putchar(' ');
}
noobcoder's Avatar, Join Date: Jul 2011
Newbie Member
Okay thanks! Great help!
noobcoder's Avatar, Join Date: Jul 2011
Newbie Member
BTW, Is there a way to cast a number like from hex to decimal? or is it just for Int, Char, and etc?
noobcoder's Avatar, Join Date: Jul 2011
Newbie Member
NVM i got it. XD