Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You could avoid the copy out of the JSON string by using a field width specifier in your printf formatting string. Those should be available in ANSI C / C89/90.

   currentToken = tokens[index];
   tokenSize = currentToken.end - currentToken.start;
 
   if(tokenSize <= 0){ continue; }
 
   printf("Current token %.*s\n", tokenSize, startOfJson + currentToken.start);


One of those things usually only people who've written printf format parser know.


The printf is just for example code.

In actual fact, I'll have to copy the data to a char array to be sent to display in the listbox.


Fair enough. I read this quite literally and thought "not exactly":

> hence I need to use those values to copy out from memory to a separate char array for printing purposes. Certainly not so trivial.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: