Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Apple Xcode
- // paulogp
- /* listagem de directoria */
- #include <stdio.h>
- #include <unistd.h>
- #define MAXC 255
- int main (int argc, const char * argv[])
- {
- char the_buffer[MAXC];
- int the_no_files = 0;
- FILE *the_fp = popen("ls", "r");
- sleep(500); // for buffer (opcional)
- while (fgets(the_buffer, MAXC, the_fp) != NULL)
- {
- printf("%s", the_buffer);
- the_no_files += 1;
- }
- printf("%d ficheiros\n", the_no_files);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement