By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,393 Members | 515 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,393 IT Pros & Developers. It's quick & easy.

i want answer in embedded c i using embedded studio (nordic semiconductor)

P: 1
print the given number with spaces in between each number?


void stringwhitesp(char *string, char *whitesp)
{
char c='0';

for (c=0; *(string+c)<='\0';c++)
{
*(whitesp + (c*2)) = *(string + c);
*(whitesp + (c*2) + 1) = ' ';
}
*(whitesp + (c*2)) = 0;
}

/**@brief Function for application main entry.
*/


//char string[MAX_SIZE];
char * pointer;
char num[] = {10,1,50,30,3,8,62,15,15,4};

char one[20];

int main(void)
{
bool erase_bonds;



// Initialize.

log_init();
timers_init();

// Start execution.

stringwhitesp(num, one);


NRF_LOG_INFO("num %d\n",NRF_LOG_PUSH (num));
NRF_LOG_INFO("one %s\n",NRF_LOG_PUSH (one));


// Enter main loop.


for(;;)
{
idle_state_handle();
}




}
2 Weeks Ago #1
Share this Question
Share on Google+
1 Reply

dev7060
Expert 100+
P: 307
What's the error?

I believe *(string+c)<='\0' should be *(string+c)!='\0'. Plus c should be of int type.
2 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.