fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. char d[] = "1010101", *p;
  6. int total = 0;
  7.  
  8. for (p = d; *p; p++)
  9. total += (*p == '1');
  10. printf("%s ==> %d\n", d, total);
  11.  
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
1010101 ==> 4