Thread: write a program that returns the file type

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    43

    write a program that returns the file type

    I need to write a short program in C where the file type is displayed when executed. Fot example ./a.out test.doc would print "the file is in .doc format".

    I'm pretty sure I need to use arg[c] and arg[v] in the code, but beyond that I'm pretty lost. Can someone show me the basic structure of how to do this?

    Thank you,
    crazychile

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    There's a FAQ entry on dealing with command line arguments.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    43
    Thanks. That FAQ actually helped!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you help me about tolower() in file
    By nctar in forum C Programming
    Replies: 7
    Last Post: 05-12-2010, 10:04 AM
  2. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM