SHARE
TWEET

Untitled

a guest Jun 5th, 2011 110 Never
  1. #include?<stdio.h>
  2. #include?<stdlib.h>
  3. #include?<string.h>
  4. #define?MAX_LINE_LEN?1024
  5. int?main()?{
  6. ????char?line[MAX_LINE_LEN];
  7. ????FILE?*in?=?fopen("/etc/passwd",?"r");
  8. ????if?(!in)?exit(EXIT_FAILURE);
  9. ????while?(fgets(line,?MAX_LINE_LEN,?in)?!=?NULL)?{
  10. ????????char?*sep?=?strchr(line,?':');
  11. ????????if?(!sep)?exit(EXIT_FAILURE);
  12. ????????*sep?=?'\0';
  13. ????????printf("%s\n",?line);
  14. ????}
  15. ????fclose(in);
  16. ????return?EXIT_SUCCESS;
  17. }
RAW Paste Data
Top