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

    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    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 Demi-God (4500 - 4999 posts)

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

    http://www.manpagez.com/man/2/fstat/


    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