Thread: getcwd( )

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    28

    getcwd( )

    Can anyone tell me why this programm causes an ilegal operation please.


    Code:
    int main( int argc, char *argv )
    {
    
          puts(getcwd( argv, argv[1] ));
       
          getch( );
       
          return 0;
       
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    int main( int argc, char *argv )
    For starters, that's wrong. It should be:
    Code:
    int main( int argc, char *argv[] )
    Next, you probably shouldn't be trying to modify argv. Make your own buffer, and use it instead.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Feb 2004
    Posts
    28
    sorry im new to c.. when you say make your own buffer you mean as in,

    Code:
    char buff[80];
    or should i copy argv[1] to buff[80]?

    been learning for a few days day & nite so forgive for my lack knowledge

  4. #4
    Registered User
    Join Date
    Feb 2004
    Posts
    28
    sorry i got it.. i should of just tried it instead of posting. thank you again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  2. getcwd() function messes up my environment variable
    By miclus in forum C Programming
    Replies: 5
    Last Post: 09-20-2004, 06:33 PM