fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main ( int argc, char *argv[] )
  6. {
  7. FILE *file = stdin;
  8. char a[50], b[50];
  9. while(1 == fscanf(file," %[^,]",a) ) /* Read data until a comma is detected, */
  10. {
  11. fgetc( file ); // Ignore , character
  12. fscanf(file," %[^,]",b); /* Read data until a comma is detected, */
  13. fgetc( file ); // Ignore , character
  14. printf("{\"%s\" : \"%s\"}\n",a,b); /* Display results into {"A":"B"} format */
  15. }
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 2012KB
stdin
Distance, 50km, Time, 2 hrs, Date, 1 Jan 2015,
stdout
{"Distance" : "50km"}
{"Time" : "2 hrs"}
{"Date" : "1 Jan 2015"}