title: Convert from MongoDB _id to string in C
body: <p>I want to use the mongodb _id attribute to guarantee uniqueness in a name.</p>
  
  <pre><code>mongo_cursor_init( cursor, &amp;conn, &amp;database );
  bson_iterator iterator[1];
  
  bson_find( iterator, mongo_cursor_bson( cursor ), "name" );
  const char *filename = bson_iterator_string( iterator );
  
  bson_find( iterator, mongo_cursor_bson( cursor ), "_id" );
  const char *mongoid = bson_iterator_string(iterator);
  
  char name[255];
  strcpy(name,filename);
  strcat(name,".");
  strcat(name,mongoid);
  </code></pre>
  
  <p>However, the variable mongoid does not get populated correctly (at all...).  I'm not sure how to find the datatype of _id.  Has anyone done this before?  Thanks!</p>
  
  <p>edit: i think the answer is in <a href="http://api.mongodb.org/c/0.4/api/bson_8h.html" rel="nofollow">here</a>, but not sure...</p>