Thread: Passing arguments to function...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    124

    Question Passing arguments to function...

    i'm using the arguments to main and then passing them to another function to open a file with the argument as the file name...this is the code:
    Code:
    int main(int argc, char* argv[])
    {
         char *fname;
         fname = argv[1];
         readFile(fname);
    }
    this is the readFile function:
    Code:
    void readFile(char *file)
    {
         ifstream fin (file);
    
    }
    it doesn't work...what am i doing wrong? i've only given the pertinent code...

    Regards,

    Farooq
    Last edited by alvifarooq; 09-24-2004 at 11:24 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Passing arguments to another function
    By Wiretron in forum C Programming
    Replies: 2
    Last Post: 12-24-2006, 05:57 AM
  5. passing counters between function
    By BungleSpice in forum C Programming
    Replies: 18
    Last Post: 02-21-2004, 06:16 PM