Search
 
SCRIPT & CODE EXAMPLE
 

C

To get file info

julien@ubuntu:~/c/shell$ cat stat.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

/**
 * main - stat example
 *
 * Return: Always 0.
 */
int main(int ac, char **av)
{
    unsigned int i;
    struct stat st;

    if (ac < 2)
    {
        printf("Usage: %s path_to_file ...
", av[0]);
        return (1);
    }
    i = 1;
    while (av[i])
    {
        printf("%s:", av[i]);
        if (stat(av[i], &st) == 0)
        {
            printf(" FOUND
");
        }
        else
        {
            printf(" NOT FOUND
");
        }
        i++;
    }
    return (0);
}
julien@ubuntu:~/c/shell$ ./stat ls /bin/ls /usr/bin/ls
ls: NOT FOUND
/bin/ls: FOUND
/usr/bin/ls: NOT FOUND
julien@ubuntu:~/c/shell$
Comment

PREVIOUS NEXT
Code Example
C :: online c compiler with mpi 
C :: c static variable 
C :: print binary in c 
C :: class to const void * 
C :: A string S is passed as the input. Two words W1 and W2 which are present in the string S are also passed as the input. The program must find the minimum distance D between W1 and W2 in S (in forward or reverse order) and print D as the output. 
C :: declaration of arrays 
C :: c programming trinary if 
C :: transpose of a matrix in c 
C :: vs code turn off formatter 
C :: arduino ip to string 
C :: time random c 
C :: CODE SOURCE POUR LISTE DOUBLEMENT CHAINEé en c 
Dart :: flutter listtile shape border 
Dart :: navigator.pushandremoveuntil flutter 
Dart :: flutter keyboard overflow when opens 
Dart :: Dart integer User input 
Dart :: change padding in text field flutter 
Dart :: flutter checkbox 
Dart :: flutter list splice 
Dart :: flutter close dialog 
Dart :: flutter linear progress indicator height 
Dart :: flutter snackbar margin 
Dart :: dart map foreach 
Dart :: how to style a text button in flutter 
Dart :: set container height flutter 25% of screen 
Dart :: looping through a list dart 
Dart :: How to change the Flutter TextButton height? 
Dart :: flutter materialpageroute no animation 
Dart :: flutter alertdialog actionsOverflowButtonSpacing 
Dart :: Counting no of word in javascript string 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =