469,300 Members | 2,165 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,300 developers. It's quick & easy.

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

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();
}




}
Sep 16 '20 #1
1 1673
dev7060
501 Expert 256MB
What's the error?

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

Post your reply

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

Similar topics

reply views Thread by =?Utf-8?B?S2luZXRpYyBKdW1wIEFwcGxpZmUgZm9yIC5ORVQg | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.