1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Rep Power

    Need some programming help...

    I'm trying to work on a C program that can accept the name of an existing file as a command line argument and also display its size(in bytes). Any tips??

    I know I need to include...
    #include <stdio.h>
    int main(int argc, char *argv[])

  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    For the file size, investigate stat, fstat, lstat functions


    Your main function must return an integer to the operating system.

    return INT_STATUS;

    And you should verify that some command line arguments were supplied.

    NULL != argv[1]

    or, more commonly,

    1 < argc
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo