How can I get the cid of the latest comment I saved using comment_save? This is my code to programmatically save comment:

  $comment = (object) array(
    'nid' =&gt; $loaded_node-&gt;nid,
    'cid' =&gt; 0,
    'pid' =&gt; 0,
    'uid' =&gt; $loaded_node-&gt;uid,
    'mail' =&gt; $account-&gt;mail,
    'thread' =&gt; '00/',
    'created' =&gt; $loaded_node-&gt;created,
    'changed' =&gt; $loaded_node-&gt;created,
    'is_anonymous' =&gt; 0,
    'homepage' =&gt; '',
    'status' =&gt; COMMENT_PUBLISHED,
    'subject' =&gt; $comment_body_subject,
    'language' =&gt; $node_language,
    'comment_body' =&gt; array(
      $node_language =&gt; array(
        0 =&gt; array (
          'value' =&gt; $comment_body_value,
          'format' =&gt; 'msg_filtered_html',
        )
      )
    ),
  );


  comment_submit($comment);
  comment_save($comment);


I want to get the cid of comment just saved. How can I get that?
The cid value should be in the comment object after it has been saved. So you should simply be able to use something like this:

comment_save($comment);
drupal_set_mesage("ID is " . $comment-&gt;cid);