10 years, 1 month ago.

problem in printing string ....

Hello ,

I am facing problem in printing string though it was printing before nicwly, please modify my program if i am wrong some where.

include "mbed.h"

Serial pc(USBTX, USBRX); tx, rx

int main() {

char stru[60]; pc.printf("\n\rHello World!\n"); r=65;

for(int i=0;i<30;i++) stru[i]= i; wait(0.5); pc.printf(" \n\r %s \n " , stru);

}

1 Answer

10 years, 1 month ago.

Hello Deepak Dandapat,

Add there a termination character at the end.

Regards,
0xc0170

Accepted Answer

u mean to sat '\0' ? i hv tried but not working,.... can yu pls send me a example code using for or while loop.

posted by Deepak Dandapat 26 Feb 2014

One more note, why are you priting values from 0 to 30, almost all of them have a special meaning, in many terminals won't be printed.. Use something easier, like values above 65.

posted by Martin Kojtal 26 Feb 2014