Advertisement
Guest User

Untitled

a guest
Nov 5th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1.     uint8_t ret=0;
  2.     char str[64]; // TODO  use malloc over length here !!
  3.     char c;
  4. //  char ** str = (char **) malloc(length * sizeof(char *));
  5.     unsigned int iter=0;
  6.     for (iter=0; iter<length;iter++)
  7.     {
  8.         int sublength;
  9.         itoa(array[iter],&c,10,&sublength);
  10.         str[iter]=c;       
  11.         printf_("itoa of %d = %d ; str[%d] now is %d \n\r",iter,c,iter,str[iter]);
  12.     }
  13.     //Now the first length character of str are the number (e.g if array= {4,5,6} then str should be {'4','5','6','whatever','whateve',...}
  14.     for(i=0;i<length;i++)
  15.     {
  16.         printf_("buffer[%d]= %d\n\r",i,str[i]);
  17.     }
  18.  
  19. Output:
  20. itoa of 0 = 48 ; str[0] now is 48
  21. itoa of 1 = 49 ; str[1] now is 49
  22. itoa of 2 = 54 ; str[2] now is 54
  23. buffer[0]= 0
  24. buffer[1]= 49
  25. buffer[2]= 54
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement