How can we get the number of rows affected by query?

Number of affected rows can be obtained as per following.

/* this should return the correct numbers of deleted records */
mysql_query(‘DELETE FROM mytable WHERE id < 10’);
printf(“Records deleted: %d\n”, mysql_affected_rows());